简体   繁体   中英

Android: explicit parallel code execution on multicore devices?

Is it possible to make use of Android multicore CPU? I'm thinking about something like C# Parallel.ForEach() ( example here ) but if there is another approach to this, I'd also like to learn it.

My calculations can be easily divided into independent pieces. I know I can simply fire multiple Threads or AsyncTasks, but without knowing CPU abilities (1/2/4 cores - can I get such info?) it may not be as effective.

Android has AsyncTasks to help with multithreaded programming. In addition, Android includes the java.util.concurrent package for all the standard Java multithreading APIs. However, there is no equivalen to PLINQ in Java.

references:

http://developer.android.com/reference/android/os/AsyncTask.html http://download.oracle.com/javase/6/docs/api/java/util/concurrent/package-summary.html

You can also use Runtime.availableProcessors() to determine the number of processors available.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM