新手白
2018-06-27 12:29
package a1;
public class Actor extends Thread {
public void run(){
System.out.println(Thread.currentThread().getName()+"是一个演员");
int count = 0;
boolean keeprunning = true;
while (keeprunning) {
System.out.println(Thread.currentThread().getName()+"登台演出"+ (++count));
if(count==100){
keeprunning = false;
}
if(count%10==0){
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
System.out.println(Thread.currentThread().getName()+"的演出结束了");
}
public static void main(String[] args) {
Thread actor = new Actor();
actor.setName("Mr.Thread");
actor.start();
Thread actrThread = new Thread(new Actress(),"Ms.Runnable");
actrThread.start();
}
}
class Actress implements Runnable{
@Override
public void run() {
}
}
Mr.Thread是一个演员
Mr.Thread登台演出1
Mr.Thread登台演出2
Mr.Thread登台演出3
Mr.Thread登台演出4
Mr.Thread登台演出5
Mr.Thread登台演出6
Mr.Thread登台演出7
Mr.Thread登台演出8
Mr.Thread登台演出9
Mr.Thread登台演出10
Mr.Thread登台演出11
Mr.Thread登台演出12
Mr.Thread登台演出13
Mr.Thread登台演出14
Mr.Thread登台演出15
Mr.Thread登台演出16
Mr.Thread登台演出17
Mr.Thread登台演出18
Mr.Thread登台演出19
Mr.Thread登台演出20
Mr.Thread登台演出21
Mr.Thread登台演出22
Mr.Thread登台演出23
Mr.Thread登台演出24
Mr.Thread登台演出25
Mr.Thread登台演出26
Mr.Thread登台演出27
Mr.Thread登台演出28
Mr.Thread登台演出29
Mr.Thread登台演出30
Mr.Thread登台演出31
Mr.Thread登台演出32
Mr.Thread登台演出33
Mr.Thread登台演出34
Mr.Thread登台演出35
Mr.Thread登台演出36
Mr.Thread登台演出37
Mr.Thread登台演出38
Mr.Thread登台演出39
Mr.Thread登台演出40
Mr.Thread登台演出41
Mr.Thread登台演出42
Mr.Thread登台演出43
Mr.Thread登台演出44
Mr.Thread登台演出45
Mr.Thread登台演出46
Mr.Thread登台演出47
Mr.Thread登台演出48
Mr.Thread登台演出49
Mr.Thread登台演出50
Mr.Thread登台演出51
Mr.Thread登台演出52
Mr.Thread登台演出53
Mr.Thread登台演出54
Mr.Thread登台演出55
Mr.Thread登台演出56
Mr.Thread登台演出57
Mr.Thread登台演出58
Mr.Thread登台演出59
Mr.Thread登台演出60
Mr.Thread登台演出61
Mr.Thread登台演出62
Mr.Thread登台演出63
Mr.Thread登台演出64
Mr.Thread登台演出65
Mr.Thread登台演出66
Mr.Thread登台演出67
Mr.Thread登台演出68
Mr.Thread登台演出69
Mr.Thread登台演出70
Mr.Thread登台演出71
Mr.Thread登台演出72
Mr.Thread登台演出73
Mr.Thread登台演出74
Mr.Thread登台演出75
Mr.Thread登台演出76
Mr.Thread登台演出77
Mr.Thread登台演出78
Mr.Thread登台演出79
Mr.Thread登台演出80
Mr.Thread登台演出81
Mr.Thread登台演出82
Mr.Thread登台演出83
Mr.Thread登台演出84
Mr.Thread登台演出85
Mr.Thread登台演出86
Mr.Thread登台演出87
Mr.Thread登台演出88
Mr.Thread登台演出89
Mr.Thread登台演出90
Mr.Thread登台演出91
Mr.Thread登台演出92
Mr.Thread登台演出93
Mr.Thread登台演出94
Mr.Thread登台演出95
Mr.Thread登台演出96
Mr.Thread登台演出97
Mr.Thread登台演出98
Mr.Thread登台演出99
Mr.Thread登台演出100
Mr.Thread的演出结束了
Actress的run方法没有逻辑代码,请问怎么出来???
哦哦哦
深入浅出Java多线程
186088 学习 · 464 问题
相似问题