playframework - Play framework 2, how to use execution context in Java? -


the official documents describe how use in scala. http://www.playframework.com/documentation/2.1.0/threadpools.

future {   // blocking or expensive code here }(contexts.myexecutioncontext) 

i can excutioncontext like:

executioncontext myexecutioncontext = akka.system().dispatchers().lookup("my-context"); 

but how add in code blow?

return async(     future(new callable<string>() {         public string call() {               return dosth();         }).map(new f.function<string,result>() {            public result apply(string i) {               return ok(i);            }         })   

i think answer should be:

    executioncontext myexecutioncontext = akka.system().dispatchers().lookup("my-context");     return async(             akka.aspromise(futures.future(new callable<string>() {               public string call() {                 return dosth();               }                }, myexecutioncontext)).map(new f.function<string,result>() {               public result apply(string i) {                 return ok(i);               }             })     ); 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -