| Author |
Inline thread
|
Grishma Dube
Ranch Hand
Joined: Jul 01, 2003
Posts: 273
|
|
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: 16695
|
|
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: 273
|
|
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: 16483
|
|
|
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: 16695
|
|
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
|
 |
 |
|
|
subject: Inline thread
|
|
|