public class ThreadSynchronizer
Synchronizes the access to the commandsMap. In order to allow parallel
execution of commands, the ClientThreads that manage remote actors locally
in the DistributedSDFDirector have to be able to access the commands
without blocking the main execution Thread in a synchronized manner.
Commands are represented by integers. It provides mechanisms to issue
sets of commands and synchronize the access to those commands by the
It is assumed that no new set of commands is issued before the previous
set of commands has been processed. Every ClientThread is responsible to
set itself as ready after performing a command.
Synchronizes access to the commands by the ClientThreads. They will
block waiting for commands to be issued. Every time a command is
fetched, it is removed from the commandsMap and all the waiting
threads are notified.
key - An object that used as the key in the commands map.
An integer representing the command.
public void setCommands(java.util.HashMap commands)
Issues a new set of commands. All the commands are copied to readyMap
that keeps track of the completed commands.No new set of commands
should be issued before the previous set has been completed. When a
new set of commands is issued all the waiting threads are notified.
commands - HashMap representing the commands.
public void setReady(java.lang.Object key)
Removes a given key from the readyMap. Wakes up all threads that are
waiting on this object's monitor.