UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Is synchronized keyword necessary, in Java, if everything that is modified in a function is local to that function?

Asked by Last Modified  

6 Answers

Learn Java

Follow 2
Answer

Please enter your answer

Technology Promoter

No, it is not required if you make sure whatever parameters are updated/modified will be done as atomic references/operations. Atomicity is an alternative to syncronizatiom.
Comments

Trainer

Not necessaring, if sharing is not there then synchronization is not required
Comments

The synchronized keyword is used in two primary contexts: as a method modifier to mark a method that it can only be executed by one thread at a time. by declaring a code block as a critical section – one that’s only available to a single thread at any given point in time
read more

The synchronized keyword is used in two primary contexts:

  1. as a method modifier to mark a method that it can only be executed by one thread at a time.
  2. by declaring a code block as a critical section – one that’s only available to a single thread at any given point in time
read less
Comments

If the function only works with local variables, then synchronized is not required. For example, a simple function for addition - "int add(int a, int b)", which takes two integers as parameter and returns summation of them, is not required to be synchronized. But if the function works on some class level...
read more
If the function only works with local variables, then synchronized is not required. For example, a simple function for addition - "int add(int a, int b)", which takes two integers as parameter and returns summation of them, is not required to be synchronized. But if the function works on some class level properties, global/static variables, or makes some calls to database system, or some I/O operation, then it may be required to make it synchronized to make the program thread safe. read less
Comments

Trainer

No, not necessary
Comments

In some cases It will be necessary. If you want to develop a thread-safe application then definitely you will have to use synchronized keyword.
Comments

View 4 more Answers

Related Questions

Does Java support pointers?
Yes and no. . The pointer model is of course supported by Java. But it has become much easier to the developer to handle it. Because Java exposes the concept of pointer in terms of reference variables...
Santosh
0 0
7
When we are used the compiler and interpreter? what is the difference between them?
Java code is the best example of compiled as well as interpreted. Java Compiler does the task of compiling . Java file to .class file(binary form). JVM works as interpreter to let Operating system understand the compiled code instructions.
Shilpa
What are the technologies to learn for a Java backend developer?
For a Java Backend Developer learn 1. Java EE or Spring Framework 2. DBMS(Database Management System) 3. Spring Boot 4. Web Services 5. ORM( Object-Relational Mapping) 6. Version Control Systems(like...
Ankita
0 0
5
What are the topics covered under core Java?
The major topics are listed below: 1. Java Basics - Variables, Data types, Operators, Control Statements,Strings, Arrays and Functions. 2. Object Oriented Concepts - Classes, Objects, Constructors, Inheritance,...
Sahil
0 0
6

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Introduction to Course Content
Video about what we are going to learn throughout the Java Training Session .

Differences Between HashMap vs HashSet In Java.
HashSet HashMap HashSet implements Set interface. HashMap implements Map interface. HashSet stores the data as objects. HashMap stores the data as key-value pairs. HashSet...

How to create excel sheets using Java?
HSSFWorkbook workbook = new HSSFWorkbook();HSSFSheet sheet1 = workbook.createSheet("actions");for (int i = 0; i < 10; i++) { sheet1.createRow(i); for (int j = 0; j < 10; j++) { HSSFRow currRow =...

Most Important Java Interview Topics
Dear All, I am here to help on java interview preparation for fresher and experienced people, please get in touch with me for further details. All interview preparation will be with unique teaching style...

Java Achieve (JAR)
Java Archieve is a binary form to bundle a Java library which equivalent to zip file. It contains .class files, .properties, .jpeg, OR any supporting files to execute this library. For Example- junit.jar,...

Recommended Articles

Java is the most commonly used popular programming language for the creation of web applications and platform today. Integrated Cloud Applications and Platform Services Oracle says, “Java developers worldwide has over 9 million and runs approximately 3 billion mobile phones”.  Right from its first implication as java 1.0...

Read full article >

Designed in a flexible and user-friendly demeanor, Java is the most commonly used programming language for the creation of web applications and platform. It allows developers to “write once, run anywhere” (WORA). It is general-purpose, a high-level programming language developed by Sun Microsystem. Initially known as an...

Read full article >

In the domain of Information Technology, there is always a lot to learn and implement. However, some technologies have a relatively higher demand than the rest of the others. So here are some popular IT courses for the present and upcoming future: Cloud Computing Cloud Computing is a computing technique which is used...

Read full article >

Java is the most famous programming language till date. 20 years is a big time for any programming language to survive and gain strength. Java has been proved to be one of the most reliable programming languages for networked computers. source:techcentral.com Java was developed to pertain over the Internet. Over...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more