What does "inline thread" mean?
I got this question during my latest interview. Anybody used this?
(new Thread() { public void run() { // do stuff } }). start();
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.
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.
"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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With