//一時停止クラス //安澤出海(泉獺) // //これだけでは何も動きません。 //メインメソッドなどで、 // TimeWait t=new TimeWait();//インスタンスを生成 // t.run();//カッコ内に数字を入れてもよい。 //などと記述すればいい。 class TimeWait extends Thread{//単純に一時停止するだけ。 public void run(){//1秒停止 try{ sleep(1000); }catch(InterruptedException e){} } public void run(int a){//指定した秒数停止。int型 a=Math.abs(a); try{ Thread.sleep(1000*a); }catch(InterruptedException e){} } public void run(double a){//指定した秒数停止。double型 a=Math.abs(a); try{ Thread.sleep((int)(1000*a)); }catch(InterruptedException e){} } public void run(byte a){//指定した秒数停止。byte型 int b=(int)Math.abs(a); try{ Thread.sleep(1000*b); }catch(InterruptedException e){} } public void run(short a){//指定した秒数停止。short型 int b=(int)Math.abs(a); try{ Thread.sleep(1000*b); }catch(InterruptedException e){} } public void run(long a){//指定した秒数停止。long型 int b=(int)Math.abs(a); try{ Thread.sleep(1000*b); }catch(InterruptedException e){} } }