Java syntax: Difference between revisions

Content deleted Content added
Line 799:
 
===Thread concurrency control===
Java has built-in tools for [[Thread (computer sciencecomputing)|multi-thread programming]]. For the purposes of thread [[Synchronization (computer science)|synchronization]] the <code>synchronized</code> statement is included in Java language.
 
To make a code block synchronized, it is preceded by the <code>synchronized</code> keyword followed by the lock object inside the brackets. When the executing thread reaches the synchronized block, it acquires a [[mutual exclusion]] lock, executes the block, then releases the lock. No threads may enter this block until the lock is released. Any non-null reference type may be used as the lock.