• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Thread-Thread Messaging

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had been searching notes for this online, but with no success untill now.

What I need to know is this. I have more than two threads running, and I need to be able to send string message from one thread to the other, using the receiver thread's name.
I actually doubt if this can be done in Java.
 
author
Posts: 23928
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rajasekhar Devi Reddy:
I had been searching notes for this online, but with no success untill now.

What I need to know is this. I have more than two threads running, and I need to be able to send string message from one thread to the other, using the receiver thread's name.
I actually doubt if this can be done in Java.



Keep in mind that threads share the heap, so you can implement the mechanism yourself. Just have all you threads register a queue (or any other data structure) in some common location. And then have your threads use this common location (class) to send messages, and to check periodically for any pending messages.

Henry
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to send messages to a specific thread, keep a queue per thread and use a wait notify mechanism to wait or process messages per thread. (Classic producer-consumer scenario)
 
It looks like it's time for me to write you a reality check! Or maybe a tiny ad!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic