Java Reference
In-Depth Information
the object. While locked, no other thread can enter the method, or enter any other synchron-
ized method defined by the object's class. When the thread returns from the method, the
monitor unlocks the object, allowing it to be used by the next thread. Thus, synchronization
is achieved with virtually no programming effort on your part.
The following program demonstrates synchronization by controlling access to a method
called sumArray( ) , which sums the elements of an integer array.
Search WWH ::




Custom Search