*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes threads 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 "threads" Watch "threads" New topic
Author

threads

FENG
Greenhorn

Joined: Jul 11, 2002
Posts: 8
what's differently lock action on an object and lock on Threads?
Thanks!
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
s3528090,
Welcome to Javaranch
We'd like you to read the Javaranch Naming Policy and change your publicly displayed name to comply with our unique rule. Thank you.
All Java objects have what we call a lock. By synchronizing some code on an object, you can obtain exclusive access to that object. Since a Thread is an object, you can also get a lock on a Thread instance. Sometimes, when a thread is executing, it needs to get the lock of some object to continue its execution. If it cannot obtain the object lock, the thread will be "suspended" until it manages to get the lock to that object.
Please, read the following for completeness:
JLS 17.13 Locks and Synchronization


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
 
jQuery in Action, 2nd edition
 
subject: threads
 
Similar Threads
static and instance methods
Introducing our new bartenders...
Yield Method Purpose to allow other high priority threads?
sleep()
K&B book example