Javaの基礎 - マルチスレッドの並べ替え

パブリッククラスTestSrotはRunnableを実装して、{ 

	プライベートint型の数を、
	
	公共INTはgetNumber(){ 
		戻り番号; 
	} 

	公共ボイドsetNumber(INT番号){ 
		this.number =番号。
	} 
	
	公共TestSrot(INT番号){ 
		スーパー()。
		this.number =数; 
	} 

	@Override 
	公共ボイドラン(){ 
		// TODO自動生成方法スタブ
		試み{ 
			のThread.sleep(this.number)。
			System.out.println(this.number)。
		}キャッチ(InterruptedExceptionある電子){ 
			// TODO自動生成キャッチブロック
			e.printStackTrace(); 
		} 
	} 
	 
	パブリック静的無効メイン(文字列[] args){
		} {[]番号= 10,2,5,12,1,50 int型。
		(int型NUM:数字)について{ 
			。新しいスレッド(新しいTestSrot(NUM))開始(); 
		} 
	} 

}

  

おすすめ

転載: www.cnblogs.com/mxh-java/p/11069518.html