一、多线程简单用法

1、Thread

Thread thread1= new Thread() {
@Override
public void run() {
System.out.println("===Threading");
}
};
thread1.start();

Runnable (相当于Thread.run()那样并不能当多线程使用,详情分析:二、多线程之Thread中run 和start 区别 

new Runnable(){
@Override
public void run(){
System.out.println("===Runnableing");
}
}.run();

2、Thread和Runnable

new Thread(new Runnable() {
@Override
public void run() {
System.out.println("===Thread and Runnableing");
}
}).start();

 

posted @ 2021-05-10 16:27  syingBlog  阅读(87)  评论(0编辑  收藏  举报