简体   繁体   English

对并发请求多次运行JAR

[英]Running a JAR multiple times with concurrent requests

I have a JAR that uses the new WatchService API to monitor a folder for uploads. 我有一个使用新的WatchService API监视要上传的文件夹的JAR。 Currently, when I execute the JAR, it detects the first upload, does it's task, exits but never runs again even with more uploads coming in. I want my JAR to run permanently, so every time an upload happens the task gets run but the JAR still checks for new uploads and will run the tasks on them also. 目前,当我执行JAR时,它会检测到第一个上载,执行任务,退出,但即使有更多上载进来,也永远不会再次运行。我希望我的JAR永久运行,因此每次上载时,任务都会运行,但是JAR仍会检查是否有新上传的内容,并且还将在它们上运行任务。

Any ideas on how I can do this? 关于如何执行此操作的任何想法?

Cheers, Matt 干杯,马特

Use a loop. 使用循环。 I assume you have a Main method that that it executes once. 我假设您有一个Main方法,该方法执行一次。 You need to build a mechanism that this action repeats until some command is received to stop. 您需要构建一种机制,该机制会重复执行此操作,直到收到停止命令为止。

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

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