- class ThreadDemo
- {
- public static void main(String[] args)
- {
- //面试
- new Thread(new Runnable(){ //匿名
- public void run(){
- System.out.println("runnable run");
- }
- })//应该在这里加start()方法才对,在下面加start()方法什么意思?
- {
- public void run(){
- System.out.println("subthread run");
- }
- }.start(); //结果:subthread run
- }
- }
复制代码 |
|