All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kangyonggan.extra.test.Demo08 Maven / Gradle / Ivy

There is a newer version: 3.2.2
Show newest version
package com.kangyonggan.extra.test;

import com.kangyonggan.extra.core.annotation.Count;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author kangyonggan
 * @since 11/6/17
 */
public class Demo08 {

    private static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");

    /**
     * 10秒内只能调用5次
     *
     * @param count
     */
    @Count(interval = 1000 * 10, count = 5, interrupt = true)
    public static char hello(int count) {
        System.out.println(String.format("时间:%s, 第%d次调用", format.format(new Date()), count));
        return 0;
    }

    public static void main(String[] args) throws Exception {
        for (int i = 0; i < 6; i++) {
            hello(i);
            Thread.sleep(1000);
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy