Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Messaging" between classes

Status
Not open for further replies.

Sen7inel

IS-IT--Management
Feb 14, 2001
90
FI
Hi,

let's say I have two classes: mainApp and myThread (extends Thread).

mainApp creates a myThread object, which does this and that, and once it does something specific, it should tell mainApp that it I've done it. Is there any neater way to do this than tell the myThread object (for example in constructor parameters: myThread th = new myThread(this);) which object called it?
 
A thread can get the ThreadGroup it belongs to:

Threadgroup myGroup = getThreadGroup();

then it can get the parent Threadgroup:

Threadgroup parentGroup = myGroup.getParent();

You can then use parentGroup.enumerate to go through all the threads looking for the one to send the message to.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top