de.fhg.igd.util
Class Signals

java.lang.Object
  extended by de.fhg.igd.util.Signals

public class Signals
extends Object

This is a convenience class for writing objects that block on signals such as closing a window. It defines a map of named objects on which threads may block until they receive notification.

Version:
"$Id: Signals.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Jan Peters

Field Summary
private  Map signals_
          This map holds the named objects.
 
Constructor Summary
Signals()
          Creates an instance of this class.
 
Method Summary
 void sendSignal(String name)
          This method signals all threads waiting on the signal with the given name.
 void waitForSignal(String name)
          This method blocks the calling thread until the signal is sent by another thread or an interrupt occurs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

signals_

private Map signals_
This map holds the named objects. Each name corresponds to a signal that may be sent and on which threads of the agent may block.

Constructor Detail

Signals

public Signals()
Creates an instance of this class. The primary purpose of this class is to initialise the map of signals.

Method Detail

waitForSignal

public void waitForSignal(String name)
This method blocks the calling thread until the signal is sent by another thread or an interrupt occurs. If no such signal already exists then a new one will be created for the given name.

Parameters:
sig - The name of the signal to wait for.

sendSignal

public void sendSignal(String name)
This method signals all threads waiting on the signal with the given name. If a signal with that name does not exists then nothing happens.

Parameters:
name - The name of the signal.


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.