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

Is Java a better programming language than C++?
If you campareboth then java has an edge n many oppurtunities compared to c++
Coaching Center
Which is a good Java training and placement institute for a fresher in Bangalore?
I know an institute in HYderabad which is giving 100% job guarantee or 100% fee refund. They have office in bangalore also, not sure whether they are offering this program in Bangalore. Please visit their...
Raja
0 0
5
Sir tell me some tips to code in java?
If you know C / C++ already, just try how will you able to achieve same examples in java. I prefer try to understand the fundamental of java and create small programs, then make the connectivity among them. Slowly build an application.
Nitinkumar
hi this iz sunil here I done with my b.sc in cs and planning to go fr java course shld I prefer for institution or a lecturer who teaches java at his own tuitions ...
i can teach you java the way you can play with real world thinking you don't need of knowledge of any other language. you can directly learn java
Sunil
0 0
5
Why Java is platform independent?
Once your java code compiled, compiled code(.class) can be executed on any os platform...if your question is HOW..it is interesting which deals with bytecode conversation
Sunita

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

Ask a Question

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