标签:ring imp xtend art string 实现 run sys star
线程的两种实现方式
(1)继承Thread类``
/**
* 继承Thread类
*
*/
public class PayThread extends Thread {
@Override
public void run() {
System.out.println("继承Thread");
}
public static void main(String[] args) {
Thread payThread = new PayThread();
payThread.start();
}
}
(2)实现Runnable接口
/**
* 实现Runnable接口
*
*/
public class PayRunnable implements Runnable {
@Override
public void run() {
System.out.println("实现Runnable");
}
public static void main(String[] args) {
Thread payThread = new Thread(new PayRunnable());
payThread.start();
}
}
标签:ring imp xtend art string 实现 run sys star
原文地址:http://blog.51cto.com/13855604/2171270