⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thread12.java

📁 java关于线程的一些实例
💻 JAVA
字号:
class Priter{
	synchronized void printChar(char ch){
		for(int i=1;i<=10;i++)
			System.out.print(ch);
	}
}
class PrinterThread extends Thread{
	Priter ptr;
	char ch;
	PrinterThread(Priter ptr,char ch){
		this.ptr=ptr;
		this.ch=ch;
	}
	public void run(){
		for(int i=1;i<=10;i++){
			ptr.printChar(ch);
			System.out.println();
		}
	}
}
public class Thread12 {
    public static void main(String[] args){
    	Priter ptr=new Priter();
    	PrinterThread pt1=new PrinterThread(ptr,'A');
    	PrinterThread pt2=new PrinterThread(ptr,'B');
    	pt1.start();
    	pt2.start();
    }
}

⌨️ 快捷键说明

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