runnable.java
来自「java技术内幕源代码,配合书籍看有事半功倍的效果」· Java 代码 · 共 41 行
JAVA
41 行
class SecondThread implements Runnable
{
Thread thread;
SecondThread()
{
thread = new Thread(this, "second");
System.out.println("Starting second thread");
thread.start();
}
public void run()
{
try {
for(int loop_index = 0; loop_index < 10; loop_index++) {
System.out.println((Thread.currentThread()).getName()
+ " thread here...");
Thread.sleep(1000);
}
} catch (InterruptedException e) {}
System.out.println("Second thread ending.");
}
}
class runnable
{
public static void main(String args[])
{
SecondThread secondthread = new SecondThread();
try {
for(int loop_index = 0; loop_index < 10; loop_index++) {
System.out.println((Thread.currentThread()).getName()
+ " thread here...");
Thread.sleep(1000);
}
} catch (InterruptedException e) {}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?