多线程代码:Runnable方法 package com.hebust.java.third; import java.util.Random; public class SaleTicket implements Runnable { public int total;public int count; public SaleTicket() {total = 100;count = 0;} public void run() {while (total > 0) {synchronized…
使用线程池与不使用线程池的差别 先来看一下使用线程池与不适应线程池的差别,第一段代码是使用线程池的: public static void main(String[] args) { long startTime = System.currentTimeMillis(); final List<Integer> l = new LinkedList<Integer>(); ThreadPoolExecutor tp = new ThreadPoolExecutor(100, 100…