有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何将swing线程设置为守护进程?

有没有办法将swing的线程设置为daemon
考虑一个启动复制操作的应用程序,同时通过jframe显示进程,因此我想将swing ui线程设置为守护进程,以便在复制线程终止后jvm杀死该线程


共 (1) 个答案

  1. # 1 楼答案

    Swing EDT已经是你所考虑的“守护进程”——在处理/隐藏所有Swing元素之后,线程将悄然退出。你可以阅读更多关于AWT Threads的内容,其中指出

    [with] the current implementation, AWT terminates all its helper threads allowing the application to exit cleanly when the following three conditions are true:

    • There are no displayable AWT or Swing components.
    • There are no native events in the native event queue.
    • There are no AWT events in java EventQueues.

    秋千也是如此