• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inline thread

 
Grishma Dube
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21496
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

Henry
 
Grishma Dube
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21496
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic