美文网首页
2019-11-19 一段可以把MacOS搞重启的java代码

2019-11-19 一段可以把MacOS搞重启的java代码

作者: Albert陈凯 | 来源:发表于2019-11-19 10:06 被阅读0次
    /**
     * @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);
    
        }
    
    }
    

    相关文章

      网友评论

          本文标题:2019-11-19 一段可以把MacOS搞重启的java代码

          本文链接:https://www.haomeiwen.com/subject/dsqwictx.html