[Java] 管理Java线程池 →→→→→进入此内容的聊天室

来自 , 2021-02-18, 写在 Java, 查看 111 次.
URL http://www.code666.cn/view/52292e0c
  1. package thread;import java.util.Vector;public class OneMain {      
  2. public static void main(String[] args) throws InterruptedException {            
  3. Vector<Integer> list = new Vector<Integer>(100);            
  4. for (int i = 0; i < 100; i++) {                  
  5. list.add(i);            }            
  6. long start = System.currentTimeMillis();            
  7. while (list.size() > 0) {                  
  8. int val = list.remove(0);                  
  9. Thread. sleep(100);//模拟处理                  
  10. System. out.println(val);            }            
  11. long end = System.currentTimeMillis();            
  12. System. out.println("消耗 " + (end - start) + " ms");      }      
  13. // 消耗 10063 ms}//源代码片段来自云代码http://yuncode.net
  14.                        

回复 "管理Java线程池"

这儿你可以回复上面这条便签

captcha