JAvaタイミングタスクネスト
1131 ワード
package com.huatek.d20150803;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
public class ScheduledTest {
public static void main(String args[]) throws Exception
{
Temp command = new Temp();
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
//
ScheduledFuture> scheduleTaskOut = scheduler.scheduleWithFixedDelay(command, 0, 10, TimeUnit.HOURS);
}
}
/**
*
*/
class Temp extends Thread
{
public void run()
{
System.out.println("Hello,out");
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
TempTwo commandTwo = new TempTwo();
//
ScheduledFuture> scheduleTaskIn = scheduler.scheduleAtFixedRate(commandTwo, 0, 5, TimeUnit.SECONDS);
}
}
/**
*
*/
class TempTwo extends Thread
{
public void run()
{
System.out.println("Hello,in");
}
}