java - Does argument (collection) to invokeAll depend on queue size? -


as far know can submit collection of callable threads invokeall , threadpool execute tasks (running tasks equal thread pool size in parallel @ given point).

but need take care of queue overflow while use invokeall?

it depends on code , business requirements. javadoc threadpoolexecutor states following use cases regards queue:

there 3 general strategies queuing:

direct handoffs. default choice work queue synchronousqueue hands off tasks threads without otherwise holding them. here, attempt queue task fail if no threads available run it, new thread constructed. policy avoids lockups when handling sets of requests might have internal dependencies. direct handoffs require unbounded maximumpoolsizes avoid rejection of new submitted tasks. in turn admits possibility of unbounded thread growth when commands continue arrive on average faster can processed.

unbounded queues. using unbounded queue (for example linkedblockingqueue without predefined capacity) cause new tasks wait in queue when corepoolsize threads busy. thus, no more corepoolsize threads ever created. (and value of maximumpoolsize therefore doesn't have effect.) may appropriate when each task independent of others, tasks cannot affect each others execution; example, in web page server. while style of queuing can useful in smoothing out transient bursts of requests, admits possibility of unbounded work queue growth when commands continue arrive on average faster can processed.

bounded queues. bounded queue (for example, arrayblockingqueue) helps prevent resource exhaustion when used finite maximumpoolsizes, can more difficult tune , control. queue sizes , maximum pool sizes may traded off each other: using large queues , small pools minimizes cpu usage, os resources, , context-switching overhead, can lead artificially low throughput. if tasks block (for example if i/o bound), system may able schedule time more threads otherwise allow. use of small queues requires larger pool sizes, keeps cpus busier may encounter unacceptable scheduling overhead, decreases throughput.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -