Java Reference
In-Depth Information
The
switch
statement examines the color currently stored in
tlc
and then assigns the
next color in the sequence. Notice that this method is synchronized. This is necessary
because it calls
notify( )
to signal that a color change has taken place. (Recall that
notify( )
can be called only from a synchronized context.)
6
. The next method is
waitForChange( )
, which waits until the color of the light is
changed.