java Android 最大线程数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35136345/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maximum number of thread Android
提问by Daniele
I want to know if there is a maximum number of threads that it is possible to run on an Android device. It depends on the type of the device?
我想知道是否有可能在 Android 设备上运行的最大线程数。这取决于设备的类型?
回答by Pankaj Nimgade
As commented by @Xaver Kapeller, you may create as many Thread
s you want but more thread
not actually the part of the solution.
正如@Xaver Kapeller 所评论的那样,您可以创建任意数量的Thread
s,但thread
实际上更多不是解决方案的一部分。
A core
(CPU) in Processor
will handle only one Task
(Process
or Thread
) at a given time.
A core
(CPU) inProcessor
将在给定时间仅处理一个Task
(Process
或Thread
) 。
so in Processor
with 1 core will handle one thread
at a time. so technically no matter how many threads you open for this processor
it will serve a thread at a given time. All threads
which are running would be using processor sequentially, utilizing quantum time of processor which only seems to be concurrent.
所以在Processor
1 个核心中将一次处理一个thread
。所以从技术上讲,无论您为此打开多少个线程,processor
它都会在给定时间为一个线程提供服务。所有threads
正在运行的都将按顺序使用处理器,利用处理器的量子时间,这似乎是并发的。
Processor
with 2 core will handle 2 threads
at a time( concurrent execution of two threads).
Processor
2 核将一次处理 2threads
个(两个线程并发执行)。
Processor
with 4 core
will handle 4 threads at a time( concurrent execution of four threads.
Processor
with 4core
将一次处理 4 个线程(四个线程的并发执行。
Processor
with 8 core will handle 8 threads
at a time( concurrent execution of eight threads. so on
Processor
8核将一次处理8threads
个(8个线程并发执行。依此类推
回答by vk239
Maximum number of threads possible to run on an Android device depends on whether the device has a 32-bit processor or a 64-bit processor and stack size of Android. But you will have memory constraints way before you reach the actual maximum limit.
Android 设备上可能运行的最大线程数取决于设备是 32 位处理器还是 64 位处理器以及Android 的堆栈大小。但是在达到实际最大限制之前,您将受到内存限制。
As mentioned in the article hereyou can run tests to determine maximum number of threads you can create in your Android version.
正如这里的文章中提到的,您可以运行测试来确定您可以在您的 Android 版本中创建的最大线程数。