groovy - Terminate existing pool when all work is done -


alright, brand new gpars please forgive me if has obvious answer.

here scenario. have piece of our code wrapped in thread.start {} block. can send messages message queue in background , not block user request. issue have ran large blocks of work, possible users perform action cause block execute again. threaded, possible second batch of messages sent before first causing corrupted data.

i change process work queue flow gpars. i've seen examples of creating pools such as

def pool = gparspool.createpool() 

or

def pool = new forkjoinpool() 

and using pool as

gparspool.withexistingpool(pool) {     ... } 

this seems account case if user performs action again, reuse created pool , actions not performed out of order, provided have pool size of one.

my question is, best way gpars? , furthermore, how know when pool finished of work? terminate when work finished? if so, there method can used check if pool has finished/terminated know need new one?

any appreciated.

no, explicitly created pools not terminate themselves. have call shutdown() on them explicitly.

using withpool() {} command, however, guarantee pool destroyed once code block finished.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -