• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Future and FutureTask in Java  RSS feed

 
Ranch Hand
Posts: 340
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand that Future is an interface and FutureTask is the implementation. But I haven't used the FutureTask in any of the code. We just mention Future as the return type along with Object type. So, what is the actual difference between these two and how FutureTask is used in the coding?
 
Vaibhav Gargs
Ranch Hand
Posts: 340
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can experts please share their views.
 
Saloon Keeper
Posts: 9239
177
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The difference is that Future is an interface and FutureTask a class implementing it. I really don't know what else I can tell you.

What is the difference between List and ArrayList?

I think there isn't much reason to use this class directly. Just use the Future references returned by an ExecutorService. If you want to create a special task that does special things during execution of the task, you can extend FutureTask.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!