I'm currently attempting to implement a java thread pool in my AS code, so that certain requests in the handleRequest function can be threaded. Currently, my code is looking like this:
inside the init function:
Code: Select all
_global.threadPool = new java.util.concurrent.Executors.newFixedThreadPool(10);
handleMovement function:
Code: Select all
function handleMovement(){
//do some code here that references the handleRequest 'params' and 'user' parameters
}
handleRequest:
Code: Select all
function handleRequest(cmd, params, user, fromRoom, protocol){
if(cmd == "m"){//this needs to be threaded
_global.threadPool.execute(handleMovement);
}
//...
}
So the thread pool is working correctly, but my question is what would be the best way to give the handleMovement function access to the parameters in the handleRequest function. Is it possible to pass parameters through the execute function? Can this be done without creating a custom java class?
Thanks.