发表于: 2017-10-19 20:51:01

1 691


今天完成的事情:

白天在面试,晚上回来回顾了一下线程的问题

public class T {
public static void main(String[] args) {
Runner runner = new Runner();
       runner.start();
//        Thread thread =new Thread();
//        thread.start();
       for (int i= 0;i<100;i++) {
System.out.println("m:"+i);
       }
}

}
class Runner extends Thread {



boolean flag = true;
   public void run() {
while (flag) {
System.out.println("========="+new Date()+"========");
       }
try {
sleep(1000);
       }catch (InterruptedException i) {
return;
       }
}
}
public static void main(String[] args) {
Runner t = new Runner();
   t.start();
   try {
try {
Thread.sleep(10000);
           t.interrupt();
       } catch (InterruptedException e) {

}

}catch (Exception e) {
return;
   }
}

}
class Runner extends Thread {
boolean flag = true;
   public void run() {
while (flag){
System.out.println("======="+new Date()+"=====");
           try {
sleep(1000);
           }catch (InterruptedException e) {
return;
           }
}
}

虽然比较简单,但是还是让我对线程有了一个比较清楚的了解

明天计划的事情:

投简历 回顾最近面试中遇到的问题

遇到的问题:

今天面试被问道线程同步...有点蒙

收获:


返回列表 返回列表
评论

    分享到