Class 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
    • Method Detail

      • isPosted

        public boolean isPosted()
        Returns:
        true if semaphore has already been posted.
      • waitEvent

        public void waitEvent()
                       throws InterruptedException
        Waits for the event to be posted.

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

        Throws:
        InterruptedException - The wait was interrupted.
      • waitTimeoutEvent

        public void waitTimeoutEvent​(int cmtTimeout)
                              throws InterruptedException
        Waits for the event to be posted. Release the thread waiting after the CMT Timeout period if no event has been posted during this timeout interval.

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

        Parameters:
        cmtTimeout - - container managed transaction timeout
        Throws:
        InterruptedException - The wait was interrupted.