Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dragos Dogaru
committed
Oct 30, 2011
1 parent
1ea49bd
commit efa0355
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
initialCode=<br>// Future objects are returned on submit to ExecutorService<br> \ | ||
// or can be created by constructing a FutureTask.<br> \ | ||
<br> \ | ||
// The Future.get() method blocks<br> \ | ||
// until some result is available.<br> \ | ||
<br> \ | ||
final Future future =<br> \ | ||
Executors.newCachedThreadPool().submit(someCallable); <br><br> \ | ||
// OR<br> \ | ||
<br> \ | ||
FutureTask<Callable> future = new FutureTask<Callable>(someCallable);<br> \ | ||
Thread thread = new Thread(futureTask);<br> \ | ||
thread.start();<br> \ | ||
<br><br><br> \ | ||
// Finally, the Future task completes<br> \ | ||
// and the block passes through.<br> \ | ||
Object result = future.get(); | ||
startExecutionBoldCode=<br>// Future objects are returned on submit to ExecutorService<br> \ | ||
// or can be created by constructing a FutureTask.<br> \ | ||
<br> \ | ||
// The Future.get() method blocks<br> \ | ||
// until some result is available.<br> \ | ||
<br> \ | ||
<b> final Future future =<br> \ | ||
Executors.newCachedThreadPool().submit(someCallable);</b> <br><br> \ | ||
// OR<br> \ | ||
<br> \ | ||
<b>FutureTask<Callable> future = new FutureTask<Callable>(someCallable);<br> \ | ||
Thread thread = new Thread(futureTask);<br> \ | ||
thread.start();</b><br> \ | ||
<br><br><br> \ | ||
// Finally, the Future task completes<br> \ | ||
// and the block passes through.<br> \ | ||
Object result = future.get(); | ||
waitForResultCode=<br>// Future objects are returned on submit to ExecutorService<br> \ | ||
// or can be created by constructing a FutureTask.<br> \ | ||
<br> \ | ||
// The Future.get() method blocks<br> \ | ||
// until some result is available.<br> \ | ||
<br> \ | ||
<b> final Future future =<br> \ | ||
Executors.newCachedThreadPool().submit(someCallable);</b> <br><br> \ | ||
// OR<br> \ | ||
<br> \ | ||
<b>FutureTask<Callable> future = new FutureTask<Callable>(someCallable);<br> \ | ||
Thread thread = new Thread(futureTask);<br> \ | ||
thread.start();</b><br> \ | ||
<br><br><br> \ | ||
// Finally, the Future task completes<br> \ | ||
// and the block passes through.<br> \ | ||
<blink><font color="red"> Object result = future.get();</font></blink> | ||
getFutureCode=<br>// Future objects are returned on submit to ExecutorService<br> \ | ||
// or can be created by constructing a FutureTask.<br> \ | ||
<br> \ | ||
// The Future.get() method blocks<br> \ | ||
// until some result is available.<br> \ | ||
<br> \ | ||
final Future future =<br> \ | ||
Executors.newCachedThreadPool().submit(someCallable); <br><br> \ | ||
// OR<br> \ | ||
<br> \ | ||
FutureTask<Callable> future = new FutureTask<Callable>(someCallable);<br> \ | ||
Thread thread = new Thread(futureTask);<br> \ | ||
thread.start();<br> \ | ||
<br><br><br> \ | ||
// Finally, the Future task completes<br> \ | ||
// and the block passes through.<br> \ | ||
<b> Object result = future.get();</b> |