thread and thread pool - does increasing thread count improve performance?
发布时间
阅读量:
阅读量
文章结构概览
-
- 提问:线程数量的增加是否意味着执行效率的提升?
-
2.举例:
-
- 例1:
- 例2:
- 解答:
- 原因:
-
3.总结
1. 提问:线程创建的越多,执行效率越高吗?
2.举例:
小标题
public static void main(String[] args) throws InterruptedException {
Long start = System.currentTimeMillis();
final Random random= new Random();
final List<Integer> list = new ArrayList<>();
for (int i=0;i<100000;i++){
Thread thread = new Thread(){
@Override
public void run(){
list.add(random.nextInt());
全部评论 (0)
还没有任何评论哟~
