其他分享
首页 > 其他分享> > 线程学习笔记

线程学习笔记

作者:互联网

image-20211029103027156

image-20211029103255766

image-20211029103321693

image-20211029103452654

image-20211029103551584

image-20211029103641334

image-20211029103717323

image-20211029103827006

image-20211029104007654

image-20211029104045315

image-20211029104412526

image-20211029104419595

image-20211029104535207

image-20211029104731585

image-20211029104912127

image-20211029105000226

package com. 1the1ma
pub1ic class MyRunnable implements Runnable {
@Override
public void run() {
for(int i=0; i<100; i++) {
System . out . print1n( Thread. currentThread() .getName()" :"+i);
}
}

    
    
 public class MyRunnableDemo {
public. static void main(String[] args) {
//创建MyRunnable类的对象
MyRunnable my = new MyRunnable();
//创建Thread类的对象,把MyRunnable对 象作为构造方法的参数
//Thread (Runnable target )
//Thread tI = new Thread(my);
//Thread t2 = new Thread(my);
//Thread (Runnable target, String name)
Thread t1 = new Thread(my, name: “高铁");
Thread t2 = new Thread(my, name: "飞机");| I
//启动线程
t1.start();
t2.start();
}
}

image-20211029112113195

image-20211029112351771

image-20211029112358919

image-20211029112417368

image-20211029113556639

image-20211029113638591

image-20211029113702241

image-20211029113832849

image-20211029114145481

image-20211029114353333

image-20211029114501060

image-20211029115201170

image-20211029115325872

image-20211029115420315

image-20211029115548762

image-20211029115622681

image-20211029115716490

标签:MyRunnable,Thread,笔记,学习,Runnable,线程,new,my,public
来源: https://blog.csdn.net/weixin_53814242/article/details/121032446