Spring Boot

Async & Scheduling

Async execution with @Async, scheduling with @Scheduled, ThreadPoolTaskExecutor, time management

25 면접 질문·
Mid-Level
1

Which annotation makes a method asynchronous in Spring?

답변

@Async marks a method for asynchronous execution. Spring executes this method in a separate thread via a TaskExecutor. Requires @EnableAsync on a configuration class to enable the mechanism. Useful for long operations (email sending, file processing) without blocking the main thread. Method can return void, Future or CompletableFuture.

2

Which annotation enables support for @Async methods in Spring?

답변

@EnableAsync activates processing of @Async annotations. It must be placed on a @Configuration class. Without this annotation, @Async is ignored and methods execute synchronously.

3

Which legacy return type allows retrieving the result of an @Async method?

답변

Future<T> is the historical return type for async methods. Allows retrieving the result via future.get() (blocking). CompletableFuture<T> is now preferred for its functional programming and better composition.

4

What is the main advantage of CompletableFuture over Future for @Async methods?

5

What is AsyncResult used for in Spring?

+22 면접 질문

다음 면접을 위해 Spring Boot을 마스터하세요

모든 질문, flashcards, 기술 테스트, 코드 리뷰 연습, 면접 시뮬레이터에 접근하세요.

무료로 시작하기