You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.1 KiB
Java

package com.ruoyi.common.event;
import java.util.concurrent.atomic.AtomicInteger;
import org.springframework.context.ApplicationEvent;
/**
* <pre>
* - 每秒都会触发的事件
* Author : J.L.Zhou
* E-Mail : 2233875735@qq.com
* Tel : 151 1104 7708
* Date : 2022年12月27日 下午3:10:39
* Version : 1.0
* Copyright 2022 jlzhou.top Inc. All rights reserved.
* Warning: this content is only for internal circulation of the company.
* It is forbidden to divulge it or use it for other commercial purposes.
* </pre>
*/
public class PerSecondEvent extends ApplicationEvent {
/**
*
*/
private static final long serialVersionUID = 1752655123185832181L;
private static AtomicInteger globalCount = new AtomicInteger(0);
private static final int MAX = 24*365*60*60;
private int count;
public PerSecondEvent() {
super(0);
if(globalCount.incrementAndGet()>MAX) {
globalCount.set(0);
}
count=globalCount.get();
super.source= count;
}
public int getCount() {
return count;
}
@Override
public String toString() {
return " 每秒都会触发的事件: " + count;
}
}