Package com.seeq.utilities
Class ManualResetEvent
java.lang.Object
com.seeq.utilities.ManualResetEvent
This class is a copy of the C# ManualResetEvent class. The .NET Framework source code is not available, so behavior
was determined by reading the documentation.
See https://msdn.microsoft.com/en-us/library/system.threading.manualresetevent(v=vs.110).aspx for more info.
-
Constructor Summary
ConstructorsConstructorDescriptionManualResetEvent
(boolean initialState) Initializes a new instance of the ManualResetEvent class with a boolean value indicating whether to set the initial state to signaled. -
Method Summary
Modifier and TypeMethodDescriptionboolean
reset()
Sets the state of the event to nonsignaled, causing threads to block.boolean
set()
Sets the state of the event to signaled, allowing one waiting thread to proceed.boolean
waitOne()
Blocks the current thread until the signal is received.boolean
waitOne
(long timeoutMilliseconds) Blocks the current thread until the signal is received or the timeout is reached.boolean
Blocks the current thread until the signal is received or the timeout is reached.
-
Constructor Details
-
ManualResetEvent
public ManualResetEvent(boolean initialState) Initializes a new instance of the ManualResetEvent class with a boolean value indicating whether to set the initial state to signaled.- Parameters:
initialState
- true to set the initial state to signaled; false to set the initial state to non-signaled.
-
-
Method Details
-
waitOne
Blocks the current thread until the signal is received.- Returns:
- true if the current instance receives a signal. If the current instance is never signaled, waitOne() never returns.
- Throws:
InterruptedException
- thrown if thread is interrupted
-
waitOne
Blocks the current thread until the signal is received or the timeout is reached.- Parameters:
timeoutMilliseconds
- The number of milliseconds to wait, or -1 to wait indefinitely.- Returns:
- true if the current instance receives a signal; otherwise, false.
- Throws:
InterruptedException
- thrown if thread is interrupted
-
waitOne
Blocks the current thread until the signal is received or the timeout is reached.- Parameters:
timeout
- The duration to wait.- Returns:
- true if the current instance receives a signal; otherwise, false.
- Throws:
InterruptedException
- thrown if thread is interrupted
-
set
public boolean set()Sets the state of the event to signaled, allowing one waiting thread to proceed.- Returns:
- true if the operation succeeds; otherwise, false.
-
reset
public boolean reset()Sets the state of the event to nonsignaled, causing threads to block.- Returns:
- true if the operation succeeds; otherwise, false.
-