当前位置 : 主页 > 编程语言 > java >

Java并发编程核心_线程的构造器

来源:互联网 收集:自由互联 发布时间:2022-07-04
package com . neu . day02 ; /** * @Author yqq * @Date 2022/03/27 16:29 * @Version 1.0 */ public class Thread01 { public static void main ( String [] args ) { //new Thread() new Thread (){ @Override public void run () { System . out . printl
package com.neu.day02;

/**
* @Author yqq
* @Date 2022/03/27 16:29
* @Version 1.0
*/
public class Thread01 {

public static void main(String[] args) {
//new Thread()
new Thread(){
@Override
public void run() {
System.out.println(Thread.currentThread().getName());
}
}.start();
//new Thread(Runnable target)
new Thread(new Runnable() {
@Override
public void run() {
System.out.println(Thread.currentThread().getName());
}
}).start();
//new Thread(Runnable target,String name)
new Thread(new Runnable() {
@Override
public void run() {
System.out.println(Thread.currentThread().getName());
}
},"name0").start();
//new Thread(String name)
new Thread("name1"){
@Override
public void run() {
System.out.println(Thread.currentThread().getName());
}
}.start();
}
}

Java并发编程核心_线程的构造器_ide


上一篇:Java并发编程核心_如何关闭一个线程
下一篇:没有了
网友评论