concurrency - How to implement a java equivalent for WaitForMultipleObjects windows API? -


we need have cleanup thread cleanup repeatedly. cleanup triggered

  1. after specified time period or
  2. 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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -