I might have been doing something really wrong. So, I have Spring's @Async
Let's say I have this piece of code
@Async("poolbeanname")
Function () {
// some code
}
I have one more, let's say I have this piece of code
@Async("poolbeanname")
Function () {
CompletableFuture.runAsync{ new Runnable ()...}
}
Now with the second code I can see, some threads got spawned but the first approach doesn't seem to spawn more than one?
To enable using @Async you should use @EnableAsync
Let’s start by enabling asynchronous processing with Java configuration – by simply adding the @EnableAsync to a configuration class:
@Configuration @EnableAsync public class SpringAsyncConfig { ... }
And you must use a public method called from other class:
@Async has two limitations:
it must be applied to public methods only
self-invocation – calling the async method from within the same class – won’t work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With