aspose file tools*
The moose likes Threads and Synchronization and the fly likes why the author start the app thread like this? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "why the author start the app thread like this?" Watch "why the author start the app thread like this?" New topic
Author

why the author start the app thread like this?

laoying Yin
Greenhorn

Joined: Sep 17, 2002
Posts: 20
Sample code:

public class Server {
ServerThread thread;

private ServerThread extends Thread {
public void run() {
Server.this.run();
}
}

public Server() {
if (thread == null) {
thread = new ServerThread();
thread.start();
}
}

public void run() {
....
}

Can somebody explain for me? or give me some tips. I don't know why the author start the server like this, what's the usage of the private inner class? Is there any advantage get from this?
Tom Johnson
Ranch Hand

Joined: May 11, 2005
Posts: 142
Call to Server constructor returns immediately and ServerThread starts in the background. Use inner class to keep it all in one handy place I guess, no other reason I can see


<a href="http://faq.javaranch.com/java/UseCodeTags" target="_blank" rel="nofollow">Use Code Tags!!</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why the author start the app thread like this?