February 2013
Intermediate to advanced
672 pages
16h 2m
English
A synchronized statement acquires a mutual-exclusion lock (§17.1) on behalf of the executing thread, executes a block, then releases the lock. While the executing thread owns the lock, no other thread may acquire the lock.
SynchronizedStatement: synchronized ( Expression ) Block
The type of Expression must be a reference type, or a compile-time error occurs.
A synchronized statement is executed by first evaluating the Expression. Then:
• If evaluation of the Expression completes abruptly for some reason, then the synchronized statement completes abruptly for the same reason.
• Otherwise, if the value of the Expression is null, a NullPointerException is thrown.
• Otherwise, let the non-null value of the Expression ...
Read now
Unlock full access