record
在这里插入代码片
package java_tel_booth;
class dht{
}
class talker extends Thread{
private dht a;
private String name;
private String[] s;
talker(dht d,String name,String[] b){a=d;this.name=name;s=b;}
public void run() {
synchronized(a) {
System.out.print(this.name+"正在使用电话亭:");
for(String q:s) {
System.out.print(q);
}
System.out.println();
}
}
}
public class App {
public static void main(String[] args) {
// TODO Auto-generated method stub
dht a=new dht();
String[] s1= {"1","2","3"};
String[] s2= {"A","B","C","D","E"};
String[] s3= {"你好,","我也好,","大家都好!"};
talker t1=new talker(a,"张三",s1);
talker t2=new talker(a,"李四",s2);
talker t3=new talker(a,"王五",s3);
t1.start();t2.start();t3.start();
}
}
写得不是很好,请多指教 🤭