concurrency - How to implement a java equivalent for WaitForMultipleObjects windows API? -
we need have cleanup thread cleanup repeatedly. cleanup triggered
- after specified time period or
- after specified event
in windows have:
dword winapi waitformultipleobjects( _in_ dword ncount, _in_ const handle *lphandles, _in_ bool bwaitall, _in_ dword dwmilliseconds );
...which wait specific events specified time. wait released when of specified event occurs or when time-out occurs.
do have similar implementation in java? tried countdownlatch , cyclicbarrier. countdownlatch cannot reset again, couldn't use , cyclicbarrier has dependency on number of threads. looking better cyclicbarrier. timer , timertask help?
one option use blockingqueue
. multiple implementations provided in java.util.concurrent
package.
your event producers put events queue.
your cleanup thread poll event, timeout, method blockingqueue.poll( long timeout, timeunit unit )
.
Comments
Post a Comment