Package org.spiderwiz.zutils
Class ZTrigger
java.lang.Object
org.spiderwiz.zutils.ZTrigger
public final class ZTrigger extends Object
Controls thread execution.
A trigger is a synchronization object with the following features:
- It can be waited on, with or without a timeout interval.
- It can be released to let the waiting thread continue.
- It can be released before it is being requested so that the requesting thread will continue without pausing.
- It can be released only if it is being requested, i.e. there is a thread pausing on it.
-
Constructor Summary
Constructors Constructor Description ZTrigger()
-
Method Summary
-
Constructor Details
-
ZTrigger
public ZTrigger()
-
-
Method Details
-
pause
public void pause(long timeout)Pauses the calling thread until the trigger is released or the given timeout interval has elapsed.The calling thread does not pause if the trigger was released before it is requested.
- Parameters:
timeout
- the maximum time to wait in milliseconds, or zero if the calling thread shall wait unlimited until the trigger is released.
-
activate
public void activate()Releases the trigger.This method can be used to release the trigger before it is being requested, so that a following request for the trigger will cause the calling thread to continue without pausing.
-
release
public void release()Releases the trigger only if it has been requested, i.e. it is paused on by another thread.Use this method if you want to release the thread (or threads) that is pausing on the trigger, but you don't want the trigger to be released before it is requested.
-