简体   繁体   English

如何将一个Java程序拆分为两个而不必分别手动运行两个程序

[英]How to split one Java program into two without having to hand-run both programs separately

I have one program that uses MVC and three threads - one thread for View / UI, one thread for Model, and one thread for Controller. 我有一个使用MVC和三个线程的程序-一个线程用于View / UI,一个线程用于Model,一个线程用于Controller。 Controller talks to model using inter-process communication, model replies with stuff that the Controller processes and then passes to the View. Controller使用进程间通信与模型进行对话,模型回复Controller处理的内容,然后传递给View。 Instead of making the model and the controller separate threads on one application, I want the model to be a separate application from the view/controller because threads are a pain and I think that separate applications will be easier to test/debug. 我希望模型不是控制器和模型在一个应用程序上分开的线程,而是希望模型是与视图/控制器分开的单独的应用程序,因为线程很痛苦,我认为分开的应用程序将更易于测试/调试。

Now, I don't actually want to have to run two separate applications every time I want to start the program. 现在,我实际上不想每次启动程序时都必须运行两个单独的应用程序。 I want to be able to click "Build/Run" in the IDE and have both applications running at the same time with a single click. 我希望能够在IDE中单击“构建/运行”,并且只需单击一下即可同时运行两个应用程序。 I don't want to click "Build/Run Application #1" and then click "Build/Run application #2". 我不想单击“构建/运行应用程序#1”,然后单击“构建/运行应用程序#2”。 I mean, they share the same code base because they used to be a single application. 我的意思是,它们共享相同的代码库,因为它们曾经是单个应用程序。 How do I get around the inconvenience of having to Build/Run two separate applications? 如何避免必须构建/运行两个单独的应用程序带来的不便? How do I make two Java applications start up together as if they were one Java application? 如何使两个Java应用程序一起启动,就像它们是一个Java应用程序一样?

如果您是IDEA的幸运用户,则可以使用Multirun插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM