Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TPL Equivalent for Java/Android

I'm curious to know if there's something similar to the Task Parallel Library from C# in Java and/or the Android SDK. Coming from a C# background, we're taught that making a new thread is a relatively heavyweight operation, and are instructed to use the threadpool, or more recently, Tasks.

So in my mind, the level of abstraction that Tasks bring would be ideal ... is there anything like that, or even the threadpool? or does it all just involve making a new Thread or making my own threadpool

like image 942
Joel Martinez Avatar asked Jun 30 '11 14:06

Joel Martinez


3 Answers

Sure it does. You can read more about it here: Executors

Also, you could overview the whole concurrency topic at the same page: Concurrency

like image 55
bezmax Avatar answered Oct 01 '22 03:10

bezmax


See http://developer.android.com/reference/java/util/concurrent/package-summary.html for threadpool info.

like image 21
Femi Avatar answered Oct 01 '22 03:10

Femi


I think that the java.util.concurrent package has most of the classes/functionality you are looking for.

Specifically, take a look at these:

  1. ThreadPoolExecutor
  2. Executors
  3. CompletionService
like image 23
nicholas.hauschild Avatar answered Oct 01 '22 03:10

nicholas.hauschild