package Play;
public class TimeCount implements Runnable {
public void run() {
int count=0;
int ban=30;
System.out.println("----------------------计时开始----------------------");
for (int i = 0; i < 1000000; i++) {
if (i < 1000000) {
try {
Thread.sleep(1000);
System.out.println("时间已过:" + i);
if (i % 30 == 0&&i!=0&& i % 60 != 0) {//&&i!=0是为了在i=0是,不打印下面的语句,因为i % 30 == 0
System.out.println("---------------" + count + "分"
+ ban + "秒---------------");
}
if (i % 60 == 0&&i!=0) {
count++;
System.out.println("---------------" + count
+ "分钟---------------");
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
public static void main(String[] args) {
TimeCount timecount = new TimeCount();
Thread timecountThread = new Thread(timecount);
timecountThread.start();
}
}
我的更多文章:
- (2014-09-26 03:39:20)
- (2014-09-26 02:30:27)
- (2014-09-26 02:27:52)
- (2014-09-25 11:41:36)
- (2014-09-24 11:25:44)
- (2014-09-24 11:24:07)
- (2014-09-24 11:22:02)
- (2014-09-24 09:41:04)
- (2014-09-22 10:46:45)
- (2014-09-22 02:32:17)