代码之家  ›  专栏  ›  技术社区  ›  David8988

我需要收集swingWorker线程吗?

  •  2
  • David8988  · 技术社区  · 7 年前

    我使用GUI调用swing worker线程。

    done() Thread.activeCount() 。我得到一个数字,表明线程仍处于活动状态。

    1 回复  |  直到 7 年前
        1
  •  2
  •   Vince    7 年前

    SwingWorker 实例。这些线程以 ThreadPoolExecutor 没有暴露。

    public final void execute() {
        getWorkersExecutorService().execute(this);
    }
    
    private static synchronized ExecutorService getWorkersExecutorService()
    

    executorService = new ThreadPoolExecutor(MAX_WORKER_THREADS, MAX_WORKER_THREADS, 10L, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>(), threadFactory);
    

    这些线程是守护进程,因此如果它们是程序中的最后一个线程,则程序仍将关闭。