*
The moose likes Beginning Java and the fly likes Basic thread use Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Basic thread use" Watch "Basic thread use" New topic
Author

Basic thread use

Krep Lock
Ranch Hand

Joined: Sep 19, 2006
Posts: 43
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

Joined: Nov 19, 2002
Posts: 349

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 ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Basic thread use
 
Similar Threads
program gets stuck
Killing process spawned by Runtime.exec()
Anonymous Class rules
Socket design question
java BigNumber 2