Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_java thread: FW: Thread questions - some asnwer


Message #1 by David Long <davidl@w...> on Fri, 17 Aug 2001 10:32:06 +0100
-----Original Message-----
From: Chanoch Wiggers 
Sent: 17 August 2001 07:47
To: 'Professional Java'
Subject: [pro_java] RE: Thread questions - some asnwer


it sounds like you are passing the current thread to the second process
rather than instantiating a seperate thread and letting it loose. Once you
have instantiated the second thread, you should have control restored to
your calling thread. Assuming that you are working in windows, as long as
the threads have equal priority (might be worth checking you ahvent given
the child thread too much priority) they should both get a piece of the
processor every so often. You also need to make sure that the calling thread
keeps a reference to the child so that it can kill the thread when your stop
button is pressed.

finally, its worth checking your polling code as that is a common pitfall in
successfully polling for responses. I wonder whether it would perhaps be
better to have a Listener rather than trying to poll so that when the button
is called you will have the listeners method automatically called - you
would probably wrap the listener in a seperate thread (if that is not
automatic?) so that your main application is freed to do other stuff.

actually, if I remember correctly, even if the class that implements the
listener is the same as you main() class, the Listener methods will be
called in a different thread so you may not have any problem with this.

chanoch

  Return to Index