FileDocCategorySizeDatePackage
EventSemaphore.javaAPI DocGlassfish v2 API4872Fri May 04 22:36:38 BST 2007com.sun.jts.CosTransactions

EventSemaphore

public class EventSemaphore extends Object
The EventSemaphore interface provides operations that wait for and post an event semaphore.

This is specifically to handle the situation where the event may have been posted before the wait method is called. This behaviour is not supported by the existing wait and notify methods.

version
0.01
author
Simon Holdsworth, IBM Corporation
see

Fields Summary
boolean
posted
Constructors Summary
EventSemaphore()
Default EventSemaphore constructor.

param
return
see


              
     
    
EventSemaphore(boolean posted)
Creates the event semaphore in the given posted state.

param
posted Indicates whether the semaphore should be posted.
return
see

        this.posted = posted;
    
Methods Summary
synchronized voidclear()
Clears a posted event semaphore.

param
return
see

        posted = false;
    
public synchronized booleanisPosted()

return
true if semaphore has already been posted.

        return posted;
    
synchronized voidpost()
Posts the event semaphore.

All waiters are notified.

param
return
see

        if( !posted )
            notifyAll();
        posted = true;
    
public synchronized voidwaitEvent()
Waits for the event to be posted.

If the event has already been posted, then the operation returns immediately.

param
return
exception
InterruptedException The wait was interrupted.
see

        if( !posted )
            wait();