Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating a thread from an existing thread  RSS feed

 
messy rebellus
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, is it possible to create a thread from an existing thread, if yes kindly tell me the way, if not kindly tell me what to do if we have such a requirement.
 
Tony Docherty
Bartender
Posts: 3264
81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, there are 2 ways of doing this:

1. Extend the Thread class, instantiate an object of your new class and call it's start() method.
2. Implement the Runnable interface, create a instance of Thread passing your Runnable object as a parameter and then call the Thread objects start() method.

For more info google for something like "Java creating threads"
[ August 13, 2007: Message edited by: Tony Docherty ]
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by messy rebellus:
is it possible to create a thread from an existing thread


Not only is it possible, it's the only way. Your program is always using threads. When it starts, it has just one user thread - the main thread - which is created automatically for you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!