如何将多线程应用程序作为线程执行?

时间:2021-07-23 21:00:58

I have Java multi-threaded application which invokes one or more jobs(java code) using threads. This application has scheduled in cron tab and one or more instances of this application got invoked in particular point time. It works well. In this case, it invoked as process.

我有Java多线程应用程序,它使用线程调用一个或多个作业(java代码)。此应用程序已在cron选项卡中进行了调度,并且在特定的时间点调用了此应用程序的一个或多个实例。它运作良好。在这种情况下,它作为进程调用。

Now, I've requirement to execute this application as thread. I have some questions to be clarified

现在,我要求以线程的形式执行此应用程序。我有一些问题需要澄清

  1. which is good method to execute a multi-threaded application, using threads or process?
  2. 哪个是使用线程或进程执行多线程应用程序的好方法?

  3. what are the bottle-necks to convert multi-threaded application to be fit into single threaded model?
  4. 将多线程应用程序转换为适合单线程模型的瓶颈是什么?

  5. This multi-threaded application has single-ton patten. If simultaneously, two threads invokes this multi-threaded application from single threaded model then ( assume synchronization present ) will it create any threads issues Or this single-ton pattens needs to be removed?
  6. 这个多线程应用程序有单吨模式。如果同时,两个线程从单线程模型调用这个多线程应用程序然后(假设存在同步)它会创建任何线程问题或者需要删除这个单吨模式吗?

Any suggestions would be appreciated

任何建议,将不胜感激

1 个解决方案

#1


0  

I had to do exactly this task - for this purposes I used nailgun. It's an old software, but can do the job very well. You will have only one JVM and each java program will run inside it, instead of a separate jvm.

我必须完成这项任务 - 出于这个目的,我使用了nailgun。这是一个旧软件,但可以很好地完成这项工作。您将只有一个JVM,每个Java程序将在其中运行,而不是单独的jvm。

EDIT: You does not need to modify you program to use with nailgun, even with singleton pattern since, as I remember, for each task(program) it use a separate classloader(be careful with memory leaks).

编辑:您不需要修改程序以使用nailgun,即使使用singleton模式,因为我记得,对于每个任务(程序),它使用单独的类加载器(小心内存泄漏)。

#1


0  

I had to do exactly this task - for this purposes I used nailgun. It's an old software, but can do the job very well. You will have only one JVM and each java program will run inside it, instead of a separate jvm.

我必须完成这项任务 - 出于这个目的,我使用了nailgun。这是一个旧软件,但可以很好地完成这项工作。您将只有一个JVM,每个Java程序将在其中运行,而不是单独的jvm。

EDIT: You does not need to modify you program to use with nailgun, even with singleton pattern since, as I remember, for each task(program) it use a separate classloader(be careful with memory leaks).

编辑:您不需要修改程序以使用nailgun,即使使用singleton模式,因为我记得,对于每个任务(程序),它使用单独的类加载器(小心内存泄漏)。