aspose file tools*
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
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Basic thread use