public static void main(String[] args){
ThreadRunnableDemo ti = new ThreadRunnableDemo();
Thread tr = new Thread(ti,"测试1");
tr.run();
Thread td = new Thread(ti,"测试2");
td.start();
}start() 和run()这两种方法有什么区别
ThreadRunnableDemo ti = new ThreadRunnableDemo();
Thread tr = new Thread(ti,"测试1");
tr.run();
Thread td = new Thread(ti,"测试2");
td.start();
}start() 和run()这两种方法有什么区别
run是运行方法
2、run 在 1 的基础上执行线程方法(run 方法)
run()方法包含本线程需要做的事情,一般,调用start()方法后,jvm会自动调用run方法