Code example for ScheduledExecutorService

Methods: scheduleAtFixedRate

0
    private volatile InEvent lastExpiredEvent = null;
    private volatile InEvent lastAllEvent = null;
 
    public LastPerTimeOutputRateManager(Long value, ScheduledExecutorService scheduledExecutorService) {
        this.value = value;
        scheduledExecutorService.scheduleAtFixedRate(new EventSender(), 0, value.longValue(), TimeUnit.MILLISECONDS);
    } 
 
    @Override 
    public synchronized void send(long timeStamp, StreamEvent currentEvent, StreamEvent expiredEvent, String groupByKey) {
        if (currentEvent != null) {
            if (currentEvent instanceof ListEvent) {
                int lastEventIndex = ((ListEvent) currentEvent).getActiveEvents() - 1;
                InEvent lastEvent = ((InEvent) ((ListEvent) currentEvent).getEvent(lastEventIndex));
                lastCurrentEvent = lastEvent;
                lastExpiredEvent = null;
                lastAllEvent = lastEvent;
                this.timeStamp = timeStamp;
            } else { 
                lastCurrentEvent = ((InEvent) currentEvent);
                lastExpiredEvent = null;