最近线程池老是遇到执行两次的情况,故作了分析,情况如下
package test;import java.util.Date;import java.util.concurrent.ExecutionException;import java.util.concurrent.Executors;import java.util.concurrent.ScheduledExecutorService;import java.util.concurrent.ScheduledFuture;import java.util.concurrent.TimeUnit;public class Test { static class EchoServer1 implements Runnable { @Override public void run() { // TODO Auto-generated method stub try { Thread.sleep(10000); i++; }