Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

returning data from a running thread

 
fadi mujahid
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
How do u return data from a running thread? run() method returns void, so you cannot return your data through it.
Any thought would be appreciated
Thanks
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you make your own subclass of Thread (let's call it MyThread), you can put whatever data you want in the MyThread object. Then, after you join the thread, look at that data.
 
Mag Hoehme
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Fadi,
check whether the join() method of the Thread class can help you to solve your problem.
 
Mag Hoehme
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Fadi,
it seems that I didn't get your question right. Here's another try: You may want to read the first draft of my essay on exactly this question at http://www.mhoehme.de/java/threads.html.
Any comments are welcome!
[ November 04, 2002: Message edited by: Mag Hoehme ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic