Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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



Why we use static and synchronized in method for single thread model example: public static syn..

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

Why we use static and synchronized in method for single thread model example: public static syn..

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

Post New Answer

More Core Java Interview Questions

What is the range of the short type?

0 Answers  


What is a qualifier in a sentence?

0 Answers  


What is multiple inheritance & can we implement it in java?

6 Answers   Satyam,


What is diffrance between FINALIZE() & FINALLY ?

2 Answers   Infosys,


What is the use of http-tunneling in rmi?

0 Answers  


What is the current version of java?

0 Answers  


What are E and PI?

1 Answers  


Difference between static synchronization vs. Instance synchronization?

0 Answers  


What do you understand by an io stream?

0 Answers  


What is OOP?

2 Answers   BMC, Microsoft,


What is a percentage sign called?

0 Answers  


when everything can be done by static block then why do we use main method?.

2 Answers  


Categories