Can the Spring @Async annotation be used on interface methods (so all implementations of that interface will implicitly have @Async on that method) or can it only be used on concrete classes?
Can the Spring @Async annotation be used on interface methods (so all implementations of
Share
I quickly tested it and having
@Asyncon an interface will make implementation asynchronous.If you want to try it yourself: You can easily test this by checking that the values of
Thread.currentThread().getId()are different (before calling the method and inside the method) or just adding aThread.sleep(10000);in the method expected to be asynchronous.Also take note the return type must be
voidorjava.util.concurrent.Future.