Why we use static and synchronized in method for single
thread model
example:
public static synchronized add(){}
Answers were Sorted based on User's Feedback
Answer / deepak verma
Synchronized static method means, the lock belongs to the
class, no other thread can access any static synchronized
method of this class when one thread already holds the lock
of that class.
This class lock is independent of locks on its object. For eg :
Class A {
public static synchronized add() {}
public synchronized void someMethod() {}
}
Here add() and someMethod() can be called concurrently as
add() is having class lock whereas someMethod() having
object lock.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / sameer
Ststic means it belongs to class.When u call a syncronized
method u keep the luck of that class.
| Is This Answer Correct ? | 2 Yes | 4 No |
Can we clone singleton class in java?
What is void data type?
What is a module function?
Difference between string s= new string (); and string s = "abv";?
What will happens if you opened Internet Explorer 4 times?
What are the Static and Dynamic Variables? Differentiate them.
How do you use equal in java?
What is the difference between normal report & matrix report?
What is the difference between preparedstatement and statement in java?
what is the difference between HashMap and Hashtable
17 Answers Value Labs, Virtusa,
What about interthread communication and how it takes place in java?
What is the core java?