e0dba7edcf69001c1989d8a2fa4db5ce
来自「这是我自己照着书上敲的」· 代码 · 共 53 行
TXT
53 行
/*
* Created on 2007-9-23
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class ThreadApplication
{
public static void main(String args[])
{
MyThread thread1=new MyThread();
MyThread thread2=new MyThread();
thread1.set('1',100);
thread2.set('2',50);
thread1.start();
thread2.start();
}
}
class MyThread extends Thread
{
char c;
int time;
int count=0;
public void set(char _c,int _time)
{
c=_c;
time=_time;
}
public void run()
{
//System.out.println(this.toString());
for(count=0;count<=50;count++)
{
System.out.print(""+c);
try
{
sleep(time);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?