并发编程
This commit is contained in:
@ -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());
|
||||
}
|
||||
}
|
@ -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());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user