Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is "inline thread"?

What does "inline thread" mean?

I got this question during my latest interview. Anybody used this?

like image 453
karthick prabhu Avatar asked Jan 04 '10 15:01

karthick prabhu


People also ask

How do you create an inline thread in Java?

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

What is thread in Java with example?

What is a Thread in Java? A thread in Java is the direction or path that is taken while a program is being executed. Generally, all the programs have at least one thread, known as the main thread, that is provided by the JVM or Java Virtual Machine at the starting of the program's execution.


2 Answers

I believe it refers to the practice of creating an anonymous class extending Thread and calling its start method in the same line of code.

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

As stated elsewhere, this is not an "official" Java term. But I think it's still good to know how concepts might be referred to differently, if only for the sake of communication.

like image 55
danben Avatar answered Oct 11 '22 10:10

danben


"inline thread" is not an established term in Java. It was a bad question.

Some people seem to use the term to mean threads defined using anonymous classes, as shown in the other answers. But again, this is not official or even widespread usage, and not something by which you could usefully measure someone's Java knowledge.

like image 44
Michael Borgwardt Avatar answered Oct 11 '22 11:10

Michael Borgwardt