java - Executors.newFixedThreadPool() - how expensive is this operation -
i have requirement need process tasks current live shows. scheduled tasks , runs every minute.
at given minute, there can number of live shows(though number cannot large, approx max 10). there more 20 functionalities needs done live shows. or 20 worker classes there , doing there job.
let first functionality, there 5 shows, after few minutes shows reduced 2, again after few minutes shows increase 7.
currently doing this,
int totalshowscount = getcurrentshowscount(); executorservice executor = executors.newfixedthreadpool(showids.size()); the above statements gets executed every minute.
problem statement
1.) how expensive above operation be..??. creating fixedthreadpool @ every given minute.
2.) can optimize solution, should use fixed thread pool, (10), , maybe 3 or 5 or 6 or number of threads getting utilized @ given minute.
can create fixed thread pool @ worker level, , maintain , utilize that.
fyi, using java8, if better approach available.
how expensive above operation be..??. creating fixedthreadpool @ every given minute.
creating thread pool relatively expensive operation can take milli-seconds. don't want doing many times per second.
a second eternity computer, if have 36 core machine can execute as 100 billion instructions in amount of time. minute very, long time, , if once minute restart jvm every minute , still reasonable throughput.
what can optimize solution, should use fixed thread pool, (10), , maybe 3 or 5 or 6 or number of threads getting utilized @ given minute.
possibly, depends on doing. without analysis sure. note: if using parallelstream(), if not should see if can, can use built in forkjoinpool.commonpool() , not need create pool. again, depends on doing.
Comments
Post a Comment