Hi All, Recently I have this problem, which really making me confused. In my code, I try to have a map where the items would expire after sometime and be deleted automatically, so I decided to use DefualtTimeoutMap. Here is how I initialize it: "TimeoutMap myMap = new DefaultTimeoutMap(null, 1*60*1000L);" As you can see I didn't passed in an instance of ScheduledExecutorService class(the first argument is null), because I thought since we have such a constructor, the ScheduledExecutorService should be taken care of behind the scene... However, as it turned out, the "run" and "purge" methods didn't get executed, and the items in the map didn't get deleted after expired. Then I looked at the source code of DefaultTimeoutMap class, I found: ... public DefaultTimeoutMap(ScheduledExecutorService executor, long requestMapPollTimeMillis, boolean useLock) { this.executor = executor; this.purgePollTime = requestMapPollTimeMillis; this.useLock = useLock; schedulePoll(); }
protected void schedulePoll() { if (executor != null) { executor.scheduleWithFixedDelay(this, initialDelay, purgePollTime, TimeUnit.MILLISECONDS); } } ... It looks like if executor is null, the scheduling won't start, in other words, we have to have a scheduler, is that right? If so, why do we have a constructor that allows null as scheduler? Please correct me if there is anything I misunderstood. Thank you very much. -- View this message in context: http://camel.465427.n5.nabble.com/Do-I-have-to-give-a-ScheduledExecutorService-instance-when-initializing-DefualtTimeoutMap-tp3298252p3298252.html Sent from the Camel - Users mailing list archive at Nabble.com.