• Post Reply Bookmark Topic Watch Topic
  • New Topic

Searching a thread by name, is possible?

 
Yeray Santana Borges
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have this enviroment:

FirstApplication --> invoke Runtime.exec() that launch by command line java -jar file.jar. --> Inside of the main method of my file.jar i create a new Thread and start it --> file.jar application finalize and my Thread is running doing a simple long process.

I need to test from FirstApplication if the thread that is started in file.jar application main method is running. Is possible locate it from my FristApplication to test if that Thread is alive?

I think that in this example the only solution is invoke a new operating system command line from FristApplication (using runtime.exec again) that inform me if the process of my Thread is running or not, but, do you know if there are other solution?

Thanks
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you use Runtime.exec to first execute the JAR it creates a process which you can use to monitor the other application for completion.

I would think you could use the Process#waitFor() method to block your FirstApplication until the JAR execution completes. If you don't want to block FirstApplication, you could find ways to constructively use waitFor() without actually blocking the rest of the app. Let me know if that is what you want and I will see what I can come up with.
 
Yeray Santana Borges
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Steve,

I will try to use the process variable returned when i invoke runtime.exec() o use waitfor to sincronized both threads.

Thank you
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!