public static void main(String[] args){
// 创建线程池,大小不定
ExecutorService executorService = Executors.newCachedThreadPool();
for (int i =0; i <8; i++) {
// 往线程池内塞任务
executorService.submit(new Runnable() {
@Override
public void run() {
System.out.println(Thread.currentThread());
SimpleKafkaProducer mm =new SimpleKafkaProducer();
mm.produce_AA(1);
}
});
}
executorService.shutdown();
}