Monday, 26 August 2013

Restrict the Number of Threads in Gpars?

Restrict the Number of Threads in Gpars?

I use GPars for parallel processes which do background tasks. I use the
following Service to start a new background thread.
To save heap memory How can I restrict the number of background threads?
How can I define a thread pool of n threads that handle my background tasks?
class TaskService {
private pool = new ForkJoinPool()
def executeAsync(args, closure = null) {
if(!closure) {
closure = args
args = null
}
GParsPool.withExistingPool(pool) {
closure.callAsync(args)
}
}
}

No comments:

Post a Comment