我们知道,在多线程中
Thread thread = new Thread(runnable);
thread.start();以及 thread.run();都可以执行runnable中run方法下的代码,但是二者又有所不同
下面给出一段代码用以体现二者的区别:
以下代码中,通过thread.start()启动线程,最终产生了线程阻塞
package com.xuecheng;
/**
* @author Zonda
* @version 1.0
* @description TODO
* @2024/6/15 16:23
*/
public class ThreadLocal {
public static void main(String[] args) {
Runnable runnable = new Runnable() {
@Override
public void run() {
synchronized (this){
while(true