标签:lin main print extend span port public 线程 1.3
线程处理
public class TestThread extends Thread{
public void run(){
System.out.println("通过继承Thread类创建线程.");
}
}
public class TestRunnable implements Runnable{
public void run(){
System.out.println("通过实现Runnable接口创建线程.");
}
}
import ahabest.TestThread;
public class RunThread {
public static void main(String[] args) {
TestThread tt = new TestThread();
Thread a1 = new Thread(tt);
a1.start();
}
}
import ahabest.TestRunnable;
public class RunRunable {
public static void main(String[] args) {
TestRunnable tr = new TestRunnable();
Thread b1 = new Thread(tr);
Thread b2 = new Thread(tr);
b1.start();
b2.start();
}
}
标签:lin main print extend span port public 线程 1.3
原文地址:https://www.cnblogs.com/Aha-Best/p/10884533.html