Javaプログラムで遅延処理をしたくてTimerクラスのテストコードを書いてみた。 コード import java.util.*; import java.util.concurrent.*; class MyTimerTest { public static void main(String[] args) throws InterruptedException { TimerTask task = new Task(); Timer timer = new Timer(); Scanner scanner = new Scanner(System.in); // 2秒後にtaskオブジェクトのrunメソッドを実行するよう // timerオブジェクトに予約 timer.schedule(task, TimeUnit.SECONDS.toMillis(2)); // キーボードからの入力