简体   繁体   English

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

[英]how to execute multi-threaded application as thread?

I have Java multi-threaded application which invokes one or more jobs(java code) using threads. 我有一个Java多线程应用程序,该应用程序使用线程调用一个或多个作业(java代码)。 This application has scheduled in cron tab and one or more instances of this application got invoked in particular point time. 该应用程序已在cron选项卡中进行了调度,并且在特定时间点调用了该应用程序的一个或多个实例。 It works well. 它运作良好。 In this case, it invoked as process. 在这种情况下,它作为流程调用。

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. what are the bottle-necks to convert multi-threaded application to be fit into single threaded model? 将多线程应用程序转换为适合单线程模型的瓶颈是什么?
  3. 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? 如果同时执行,则两个线程从单线程模型调用此多线程应用程序(假设存在同步),它将创建任何线程问题吗?还是需要删除此单吨模式?

Any suggestions would be appreciated 任何建议,将不胜感激

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 . 您将只有一个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一起使用,即使是单例模式也是如此,因为据我记得,对于每个任务(程序),它都使用单独的类加载器(请注意内存泄漏)。

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

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