aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Class Level Locking Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Class Level Locking" Watch "Class Level Locking" New topic
Author

Class Level Locking

Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
How locking mechanism will wotk for class level?

Suppose if we synchronize a non-static method in a class, then not more than one thran can access the synchronized non-static method, but however more than one threads can still access the methods which is not synchronized on the same object.

What about when using synchronization for a static method? it's a calss level lock..correct..? Can a thread can access any method which is not synchronized in that class?


Micheal John
SCJP 1.4 (86%), SCWCD 1.4 (86%), SCBCD 1.3 (85%), SCDJWS (Just Started...) - Satisfaction Lies in Our EFFORT, Not in the ATTAINMENT
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Micheal John posted December 09, 2006 05:50 AM

What about when using synchronization for a static method? it's a calss level lock..correct..? Can a thread can access any method which is not synchronized in that class?


Yes, you say: all static synchronized methods can only be called from one thread at the same time. Means they are synchronized.

All methods that are not static and not synchronized are - errr - not synchronized.


Bu.


all events occur in real time
 
Consider Paul's rocket mass heater.
 
subject: Class Level Locking