有些代码不懂!!
public class Machine extends Thread{private static StringBuffer log=new StringBuffer();
private static int count=0;
public void run(){
for(int a=0;a<20;a++){
log.append(currentThread().getName()+":"+a+" ");
if(++count%10==0) log.append("\n"); }
}
public static void main(String args[])throws Exception{
Machine machine1=new Machine();
Machine machine2=new Machine();
machine1.setName("m1");
machine2.setName("m2");
machine1.start();
machine2.start();
while(machine1.isAlive()||machine2.isAlive())
Thread.sleep(500);
System.out.println(log);
}
}
粗体部分是什么意思啊?
private static StringBuffer log=new StringBuffer();是什么意思?
log.append()又是什么意思?
public static void main(String args[])后面为什么要加加throws Exception
[[it] 本帖最后由 feifeimao 于 2008-7-21 18:26 编辑 [/it]]