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 |
An inner class can actually be a subclass of the outer class? a. true b. false
Explain the difference between collection api and stream api in java8?
What is java and why do we need it? Explain
What is the range of the short type?
How do you use wildcards?
how to open and edit XML file in Weblogic???
Explain importance of inheritance in java?
Given a singly linked list, how will you print out its contents in the reverse order? Can you do it with consuming any extra space?
0 Answers Akamai Technologies,
What is a newline character in java?
Can we have multiple catch block for a try block?
What is an exception?
What are the advantages of encapsulation in java?