File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
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: 91
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: 4181
    
  21

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