Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Can you assign unique thread ids and access thread from external program? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Can you assign unique thread ids and access thread from external program?" Watch "Can you assign unique thread ids and access thread from external program?" New topic
Author

Can you assign unique thread ids and access thread from external program?

Prasad prap
Greenhorn

Joined: Sep 26, 2008
Posts: 28
I am currently implementing a program that requires me to handle threads and process.

IDEA:

1. There are multiple java processes running and each process may have multiple threads. Current java implementation is such that thread ids in java is unique for a particular process but not within the processes. So is there a way I could implement a unique thread ids among multiple processes?

2.Also, I need to implement an external java program that monitors these threads. By monitoring I mean, depending upon some logic I need to notify a particular thread(using unique thread id) regarding an event. Is there a way that I can access thread from external program. If yes how?

3) Can I use ThreadGroup for this? How does this work?

Are there any other solutions to implement the similar idea?

Thank you in advance.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

Yes, I expect you could do something like that with a suitable JMX monitoring design. Particularly your question (2).
Prasad prap
Greenhorn

Joined: Sep 26, 2008
Posts: 28
Hey thats great. But I still have a question that whether I will be getting the thread info of all the processes?
For eg:

Suppose there are two processes A, B and each process has three threads 1,2,3.
So using JMX will that be possible to get information about A:1, A:2, A:3 and B:1, B:2, B:3?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

As long as the data is available to Java code it is available to JMX (which of course is just Java code itself).
Prasad prap
Greenhorn

Joined: Sep 26, 2008
Posts: 28
What I mean to say is that can I get all process and thread information at once?
Like is it possible for me to access any process any thread?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

What part of my previous answer did you not understand?
 
jQuery in Action, 2nd edition
 
subject: Can you assign unique thread ids and access thread from external program?