what's differently lock action on an object and lock on Threads? Thanks!
posted 13 years ago
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