testthreadmethod.java

来自「《Java程序设计与应用》-张仕斌-源程序 《Java程序设计与应用》-张仕斌」· Java 代码 · 共 32 行

JAVA
32
字号
/*
 * TestThreadMethod.java
 *
 * Created on 2006年10月19日, 下午12:10
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package example9_7;

/**
 *
 * @author Administrator
 */
public class TestThreadMethod extends Thread{
    
    /** Creates a new instance of TestThreadMethod */
    public TestThreadMethod() {
    }
public static int shareVar = 0;
	public TestThreadMethod(String name){super(name);}
	public synchronized void run(){
		for(int i=0; i<4; i++){
			System.out.print(Thread.currentThread().getName());
			System.out.println(" : " + i);
			Thread.yield();
		}
	}
    
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?