/**
* @author Albert
*/
@Slf4j
public class MacCrash {
private static final AtomicInteger index = new AtomicInteger();
public static void main(String[] args) {
log.info("start");
run();
}
public static void run() {
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1000, Integer.MAX_VALUE, Integer.MAX_VALUE, TimeUnit.DAYS, new ArrayBlockingQueue(1));
ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
try {
for (;;) {
KeyStreamingChannel<String> accept = this::accept;
accept.onKey("abc");
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void accept(String url) {
threadPoolExecutor.submit(() -> System.out.println(index.getAndIncrement()));
}
}, 0, 1, TimeUnit.SECONDS);
}
}
网友评论