例七.txt
来自「java电子版源码 java电子版源码」· 文本 代码 · 共 37 行
TXT
37 行
class A implements Runnable
{
Thread thread;
int n=0;
A()
{
thread=new Thread(this);
}
public void run()
{
while(true)
{
n++;
System.out.println("你好!");
try{
Thread.sleep(1000);
}
catch(InterruptedException e)
{
}
if(n==5)
{
thread=new Thread(this);
thread.start();
}
}
}
}
class Example
{
public static void main(String args[ ])
{
A a=new A();
a.thread.start();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?