开发者

Android: explicit parallel code execution on multicore devices?

开发者 https://www.devze.com 2023-04-10 05:06 出处:网络
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.

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 b开发者_JAVA百科e 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号