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

Please tell me what Object Oriented Programming and Object Based Programming with reallife example..what is the difference between them.?
Hi Ritesh, In order to be a true object oriented programming language, following 4 need to be present… 1) Abstraction - Hiding the implementation details from the user, only the functionality will...
Ritesh
What are the qualities of a good Java trainer?
Good java trainers are always teaching their students with practical examples. This exactly happens in BEE Apprentice, our trainers are working in MNCs hence they are updated with technology and are best trainers.
Venu
0 0
5
What is the best book to learn data structures using Java?
There are several excellent books that can help you learn data structures using Java. 1. "Data Structures and Algorithms in Java" by Robert Lafore. 2. "Algorithms, Part I" by Robert Sedgewick and Kevin...
Shubham
0 0
5
in java every thing is in the form of object
Everything is object is java except primitive data types like int,long etc..thats the reason its not 100 % object oriented language..
Abrar
What are the core concepts of Java?
OOPS, Exceptions, Multi threading
Manish
0 0
5

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

Ask a Question

Related Lessons

Java : Compile-time Versus Runtime optimization
While designing and development, one should think in terms of compile-time and run-time.It helps in understanding language basics in a better way.Let's understand this with a question below : What...
S

Easy way to remember Java keyword.
ACCESS MODIFIER ACCESS SPECIFIER abstract, assert, const, final, native, static, strictfp, super, synchronized, this, transient, void, volatile public, private, protected, default DATA...

Rohit Deshbhratar

1 0
0

TestNG Annotations and its sequence
public class TestNGAnnotations { @BeforeMethod public void beforeM() { System.out.println("Before Method"); } @AfterMethod public void afterMethod() { System.out.println("After Method"); } @BeforeClass...
S

Sarthak C.

0 0
0

Java : Command Line Arguments
The parameters which are provided to the program at the command line. Eg:d:\>java a 10 20 30 Here,“java” is an interpreter, “a” is filename,10,20,30 are arguments passed to...
S

Svg Reddy

0 0
0

Java Collection
Collection: The collection provides an architecture like a list where we can store and manipulate the group of items. Through Collections, we can achieve operations such as searching, sorting, insertion,...

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