如何在 Netbeans 平台应用程序上启动自定义非 UI 线程?
How do you start custom non-UI threads on a Netbeans platform application?
问:如何在 Netbeans 平台应用程序上启动自定义非 UI 线程?
这对我来说对 swing 应用程序来说从来都不是问题,因为我有一个主要的 class 可以使用。
这是我过去的做法。
//Execute main method.
public static void main(String args[])
{
//Start thread 1.
(new Thread(new ThreadClass1())).start();
//Start thread 2.
(new Thread(new ThreadClass2())).start();
//Start thread 3.
(new Thread(new ThreadClass3())).start();
}
我确实更喜欢 net-beans 平台,但它管理这些启动功能的方式与我习惯的不同。提前谢谢你。
new ThreadClass1().start()
这是启动线程的默认方式。
我找到了我的问题的答案,我想把它写出来。
我有一个名为 StartupClass.java 的 class,您需要在模块清单中将其声明为:
OpenIDE-Module-Install: parentFolder/StartupClass.class
代码如下:
import org.openide.modules.ModuleInstall;
public class StartupClass extends ModuleInstall
{
//This method is executed at startup.
@Override
public void restored()
{
//Start thread 1.
(new Thread(new ThreadClass1())).start();
//Start thread 2.
(new Thread(new ThreadClass2())).start();
//Start thread 3.
(new Thread(new ThreadClass3())).start();
}
}
希望这对需要的人有所帮助。
问:如何在 Netbeans 平台应用程序上启动自定义非 UI 线程?
这对我来说对 swing 应用程序来说从来都不是问题,因为我有一个主要的 class 可以使用。
这是我过去的做法。
//Execute main method.
public static void main(String args[])
{
//Start thread 1.
(new Thread(new ThreadClass1())).start();
//Start thread 2.
(new Thread(new ThreadClass2())).start();
//Start thread 3.
(new Thread(new ThreadClass3())).start();
}
我确实更喜欢 net-beans 平台,但它管理这些启动功能的方式与我习惯的不同。提前谢谢你。
new ThreadClass1().start()
这是启动线程的默认方式。
我找到了我的问题的答案,我想把它写出来。
我有一个名为 StartupClass.java 的 class,您需要在模块清单中将其声明为:
OpenIDE-Module-Install: parentFolder/StartupClass.class
代码如下:
import org.openide.modules.ModuleInstall;
public class StartupClass extends ModuleInstall
{
//This method is executed at startup.
@Override
public void restored()
{
//Start thread 1.
(new Thread(new ThreadClass1())).start();
//Start thread 2.
(new Thread(new ThreadClass2())).start();
//Start thread 3.
(new Thread(new ThreadClass3())).start();
}
}
希望这对需要的人有所帮助。