スレッド動作を指定秒ストップさせることができます。
次のようなプログラムを作成して実行してみます。
package ThreadPackage;
public class Ts {
/**
* @param args
*/
public static void main(String[] args) {
//スレッドの動作がsleep秒ごとにどんどん遅くなっていく
for(int i=0; i<10; i++){
int tm = i * 1000;
System.out.println("Start tm -> " + tm);
try {
Thread.sleep(tm);
}catch(InterruptedException e){
}
}
}
}
実行結果は以下のようになり、下に行けば行くほど表示する時間間隔が長くなっていきます。
Start tm -> 0 Start tm -> 1000 Start tm -> 2000 Start tm -> 3000 Start tm -> 4000 Start tm -> 5000 Start tm -> 6000 Start tm -> 7000 Start tm -> 8000 Start tm -> 9000
単純にとあるループ処理を10回繰り返すだけですが、ループ中に
Thread.sleep(tm);
と記載し、tm秒ごとに処理を一時停止しています。