自定义一个类继承Thread- public class TheradDemo extends Thread{
- @Override
- public void run() {
- // TODO Auto-generated method stub
- super.run();
- }
- }
复制代码 然后创建其对象
- public class ExThreadDemo {
- public static void main(String[] args) {
- Integer ii = 10;
- ThreadDemo t = new ThreadDemo();
- }
- }
复制代码 结果t只能定义为ThreadDemo或Object,不能定义为Thread,也调用不了start方法,连run都调用不了
头都大了
|
|