I was following along to the following tutorial - Derek Banas Java tutorial 18 - Threads pt2 and as I decided to go over his tutorial series by following along in notepad++ and compiling with the command line, so that I can experiment and test things I'm unsure about, I figured the problem I encountered must be an error in the my typing. However, after skipping to the second stage, which is when I download his commented source code and read over it in eclipse, I noticed his code was identical. I then opened my code in eclipse and got the same error I was getting in the command line, until I pasted his line above it. Though identical the error disappeared?! when I removed the line again the code went back to its broken state. I'm totally confused.
Below is my code:
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class JavaLesson18t{
public static void main(String[] args){
addThreadsToPool();
}
public static void addThreadsToPool(){
ScheduledThreadPoolExecutor eventPool = new ScheduledThreadPoolExecutor(5);
eventPool.scheduleAtFixedRate(new CheckSystemTime(), 0, 2, SECONDS);
eventPool.scheduleAtFixedRate(new PerformSystemCheck("Mail"), 5,5,SECONDS);
eventPool.scheduleAtFixedRate(new PerformSystemCheck("Calendar"), 0, 2, SECONDS);
System.out.println("Number of Threads: " + Thread.activeCount());
}
}
And below is the line that when pasted into this code in eclipse, magically fixes the problem..
eventPool.scheduleAtFixedRate(new CheckSystemTime(), 0, 2, SECONDS);
Please advise, I really don't know whats going on here..