📜  可运行的 java 代码示例

📅  最后修改于: 2022-03-11 14:52:45.441000             🧑  作者: Mango

代码示例1
public class RunnableDemo {
  
    public static void main(String[] args) {
        System.out.println("Main thread is - " + Thread.currentThread().getName());
      
        Thread t1 = new Thread(new RunnableDemo().new RunnableImpl());
      
        t1.start();
    }
  
    private class RunnableImpl implements Runnable {
        public void run() {
            System.out.println(Thread.currentThread().getName()
                             + ", executing run() method!");
        }
    }
}