https://kotlinlang.org logo
g

groostav

07/05/2017, 8:39 AM
I've got a lot of polling/blocking-call concurrency happening on my desktop application and im looking to get some of thes ethings to start sharing threads. Many of them have
while(true) { doBlockingCall(); sleep(PollPeriod); }
I was thinking I could use a
ScheduledThreadPoolExecutor
with
scheduleAtFixedRate
to get these threads to do something during their off-duty cycle. The problem is I intrinsically need an unbounded thread pool since I dont have any static gaurantees about how many blocking-callers there will be. I figured I'd follow this: https://stackoverflow.com/a/21998149/1307108 bad idea.
ensurePrestart()
will create a new thread regardless of whether or not a thread is available if your core pool size is not met. Anybody have any suggestions?