I can't get this code to compile, and I'm really pissed....Someone please help:
import java.io.*;
import java.util.*;
import static java.util.concurrent.TimeUnit.*;
public class ScheduleTester
{
public static void main(String[] args)
{
/**
Get a scheduler
**/
ScheduledExecutorServer scheduler =
Executors.newSingleThreadScheduledExecutor();
/**
Get a handle, starting now, with a 10 second
delay
**/
final ScheduledFuture<?> timeHandle =
scheduler.scheduleAtFixedRate(new TimePrinter(System.out),0,10,SECONDS);
/**
Schedule the event, and run for 1 hour
**/
scheduler.schedule(new Runnable() {
public void run()
{
timeHandle.cancel(false);
}
}, 60*60, SECONDS);
}
}
}
class TimePrinter implements Runnable
{
private PrintStream out;
public TimePrinter(PrintStrea out)
{
this.out = out;
}
public void run()
{
out.printf("Current time: %tr%n", new Date());
}
}