📄 j_thread.java.bak
字号:
// ////////////////////////////////////////////////////////
//
// J_Thread.java
//
// Created by Jun-Hai Yong, on XX xx, xxxx (Date)
// ////////////////////////////////////////////////////////
// Readme:
// Modify the previous program using Runnable Interface.
// ////////////////////////////////////////////////////////
// Using this example, please explicitly refer to the book:
// Jun-Hai Yong. Programming in Java.
// Beijing: Tsinghua University Press, 2004.
// 使用本例子,请注明引用:
// 雍俊海. Java 程序设计. 北京: 清华大学出版社, 2004.
// Please note that the author and publisher make no
// warranty of any kind on the examples provided.
// ////////////////////////////////////////////////////////
public class J_Thread implements Runnable
{
private int m_threadID;
public J_Thread(int i)
{
System.out.println("Create thread: " + i );
m_threadID=i;
} // End of method: J_Thread
public void run( )
{
for(int i=0; i<3; i++)
{
System.out.println(" Running thread: " + m_threadID);
try
{
Thread.sleep((int)(Math.random( ) * 1000));
}
catch ( InterruptedException ex )
{
System.err.println(ex.toString( ));
}
} // End of loop: for
} // End of method: run
public static void main( String args[] )
{
Thread t1= new Thread(new J_Thread(1));
t1.start( );
Thread t2= new Thread(new J_Thread(2));
t2.start( );
System.out.println("End of main");
} // End of method: main
} // End of class: J_Thread
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -