public void Start(ExecutorService timer, int storageIntervalMillis) { timer.ScheduleAtFixedRate(StorageMaintenanceTask, null, storageIntervalMillis, storageIntervalMillis); }
public void Init(Peer peer, ExecutorService timer) { _peer = peer; _timer = timer.ScheduleAtFixedRate(Run, null, IntervalMillis, IntervalMillis); // MSDN: The method can be executed simultaneously on two thread pool threads // if the timer interval is less than the time required to execute the method, or // if all thread pool threads are in use and the method is queued multiple times. }
private void Initialize(ChannelHandlerContext ctx) { switch (_state) { case 1: return; case 2: return; } _state = 1; // .NET-specific: if (_executor == null) { _executor = new ExecutorService(); } var currentMillis = Convenient.CurrentTimeMillis(); _lastReadTime.Set(currentMillis); _lastWriteTime.Set(currentMillis); _timer = _executor.ScheduleAtFixedRate(Heartbeating, ctx, TimeToHeartBeatMillis, TimeToHeartBeatMillis); }