AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHh
I can't get this to compile......PLEASE help. It's just something simple that demonstrates scheduling tasks in 1.5, but it wont compile.
Code: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()); } }


Reply With Quote