aspose file tools*
The moose likes Threads and Synchronization and the fly likes Create new Thread with FutureTask vs using Executor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Create new Thread with FutureTask vs using Executor" Watch "Create new Thread with FutureTask vs using Executor" New topic
Author

Create new Thread with FutureTask vs using Executor

Swerrgy Smith
Ranch Hand

Joined: Mar 26, 2010
Posts: 84
Hi,

I know that we can execute a FutureTask by calling:



However, if we create a new Thread with FutureTask in the classical way (because FutureTask also implements Runnable), what will be the difference?



In any case, we can still call to get the execution result.

Thanks.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3949
    
  17

The difference is the executor will use a Thread pool to execute the task, re-using threads when possible. Also, depending on which executor you use, you could get a Queue with multiple Futures returned in the order of completion.


Steve
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Create new Thread with FutureTask vs using Executor
 
Similar Threads
Using FutureTask with Tomcat's thread pool
Thread question
Catching exception from a Thread
how to generate thread in web application
use of FutureTask