← All tutorials

GoCareerGo Tutorials

Spring Boot Tutorial

Auto-configuration, REST APIs, JPA, AOP, caching, microservices and Spring Cloud.

Asynchronous Methods (@Async)

Runs a method on a separate thread so the caller doesn't block waiting for it to finish.

@EnableAsync
@Service
public class EmailService {
    @Async
    public void sendWelcomeEmail(String to) {
        // runs on a background thread pool
    }
}
Tip

Mention the caveat: @Async only works on calls made from OUTSIDE the class (self-invocation bypasses the proxy).