如何在lambda表达式上使用注释

时间:2019-11-25 16:34:32

标签: java lambda annotations sonarqube runnable

如何将此匿名类转换为lambda表达式:

new Runnable() {
        @Override
        @Scheduled(fixedDelay = 10000)
        public void run() {
            System.out.println("Runnable as anonymous class");
        }
    }

我进行这样的转换:

Runnable r = ()->{System.out.println("Runnable as Lambda expression");};

但是当我尝试放置注释@Scheduled(fixedDelay = 10000)

时出现编译错误

0 个答案:

没有答案