并发编程

This commit is contained in:
罗祥
2019-11-24 08:37:29 +08:00
parent 910790be8c
commit 5333702053
6 changed files with 227 additions and 34 deletions

View File

@ -0,0 +1,16 @@
package com.heibaiying.createThread;
public class J1_Method01 {
public static void main(String[] args) {
System.out.println("Main线程的ID为" + Thread.currentThread().getId());
Thread thread = new Thread(new CustomRunner());
thread.start();
}
}
class CustomRunner implements Runnable {
@Override
public void run() {
System.out.println("CustomThread线程的ID为" + Thread.currentThread().getId());
}
}

View File

@ -0,0 +1,16 @@
package com.heibaiying.createThread;
public class J2_Method02 {
public static void main(String[] args) {
System.out.println("Main线程的ID为" + Thread.currentThread().getId());
CustomThread customThread = new CustomThread();
customThread.start();
}
}
class CustomThread extends Thread {
@Override
public void run() {
System.out.println("CustomThread线程的ID为" + Thread.currentThread().getId());
}
}