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 sort hashmap in java?
What are multiple inheritances?
What is use of static method?
What is the difference between getCodeBase and getDocumentBase methods?
1 Answers CS Business Services,
if arraylist size is increased from initial size what is the size of arraylist...suppose initial is 100 , if i add 101 element what is the size...
What are predicates in java 8?
Name the method of a Container that can be used to cause a container to be laid out and redisplayed?
what are Hostile Applets?
What package is math in java?
Name two subclasses of the TextComponent class?
What is singleton pattern?
Why array is used in java?