This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Runnable Issue  RSS feed

 
awad saleh
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone..

As we know we create an object of interface. Then why the below program is getting executed..?
I need an explanation how it is getting executed.....?


public class Test {
public static void main(String[] args) {
new Thread(new Runnable() {
public void run() {
System.out.println("Hello!");
}
}).start();
}
}


Thank Q.
 
arulk pillai
Author
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is creating an inner class and executing the run() method. Have a look at Java inner classes.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!