Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6159393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:07:32+00:00 2026-05-23T21:07:32+00:00

I am currently implementing a program that requires me to handle threads and process.

  • 0

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. Are there any other solutions to implement the similar idea?

Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:07:33+00:00Added an answer on May 23, 2026 at 9:07 pm

    You could use a concatenation of the process id and the thread id to uniquely identify a thread – for instance, thread 23 in process 7038 could be identified as 7038:23. This has the advantage that given a thread identifier, you can tell which process the thread belongs to.

    I doubt that it is possible for one process to control the threads of another. You probably need to use some form of inter-process communication, such as RMI, named pipes, or TCP. Each process should probably have one thread that waits for an incoming message, parses it, and notifies the appropriate thread based on the contents of the message.

    A very simple example of what a TCP-based solution might look like: Every worker process has a thread that listens for TCP connections from the monitoring process; it is expected that when the monitoring process connects, it will write one line containing the id of a thread in this worker process. The worker process must keep e.g. a HashMap that maps thread ids to Thread objects.

    ServerSocket socket = new ServerSocket(6789);
    while (true) {
        Socket connectionSocket = welcomeSocket.accept();
        BufferedReader socketReader = new BufferedReader(new InputStreamReader(
                                          connectionSocket.getInputStream()));
        String line = socketReader.readLine();
        int threadId = Integer.parseInt(line);
        // Now, use threadId to locate the appropriate thread 
        // and send a notification to it.
    }
    

    There should probably also be a way for the monitoring process to ask a worker process for all its thread ids. The worker process can simply maintain a list of process ids (and which port each process listens to) and, for each process id, a list of the thread ids inside that process.

    By the way, as @parsifal said, it would be interesting to know what you are actually trying to achieve.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently developing a percussion tutorial program. The program requires that I can determine
I'm currently working on a small utility program that only requires a command line
I'm currently in the process of implementing a number of different assignment algorithms for
I am implementing a RESTful web service that currently handles JSON and needs to
I'm currently implementing a Monotouch application that will eventually be ported to Monodroid. The
I am currently implementing a Deck class that represents a 52 card playing deck.
I'm implementing a classical map-reduce program in which I have a parent that spwans
I am currently implementing a view in Android that involves using a larger than
I'm currently implementing a service that uses WCF discovery and provides Discovery Endpoint and
I'm currently implementing a raytracer. Since raytracing is extremely computation heavy and since I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.