Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Basic thread use

 
Krep Lock
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking thru some source code I ran across this:



1) does new Thread(this) "fork" the process that's running main() and give the spawned copy to aLoop? Is this typical usage for a simple process that a programmer doesn't want to prepare in a separate class?

2) aLoop.start() looks for a run() method and begins a stack with that, right?
 
Abhinav Srivastava
Ranch Hand
Posts: 354
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does new Thread(this) "fork" the process that's running main() and give the spawned copy to aLoop? Is this typical usage for a simple process

The actual thread will only be created after start() is invoked. new Thread() is specifying where run() is implemented.
You will do this if you want to keep main() and run() running concurrently(i.e. in two different threads).
[ January 15, 2008: Message edited by: Abhinav Srivastava ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic