File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes Inline thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Inline thread" Watch "Inline thread" New topic
Author

Inline thread

Grishma Dube
Ranch Hand

Joined: Jul 01, 2003
Posts: 275
Hi,

Whats the advantages of having inline thread over thread created by extending or implementing thread.

In what scenario we will need inline thread.

Thanks,
Grishma
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18508
    
  40


Please elaborate on what you mean by "inline thread", as that is not a standard term.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Grishma Dube
Ranch Hand

Joined: Jul 01, 2003
Posts: 275
Inline thread is when you create a thread without extending Thread class or implementing runnable interface...

new Thread(){
public void run(){
// do stuff
}}.start();

I know it works this way, but not able able to understand the use of it.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

That's called an "anonymous inner class", and your example shows an anonymous inner class which does in fact extend the Thread class. I'm not sure what you question is about this class, though.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18508
    
  40

Paul Clapham wrote:That's called an "anonymous inner class", and your example shows an anonymous inner class which does in fact extend the Thread class. I'm not sure what you question is about this class, though.


Well, since the premise of the question assumes that an "inline thread" doesn't actually extend the Thread class -- which it actually does -- I think that this topic is now likely moot.

Henry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inline thread
 
Similar Threads
Returning multiple values in Java
Implementing thread in an applet
Is this correct ?
Certifications revisited (was: Javaranch's image discussion)
private methods