ExecutorService quản lý thread pool, tách biệt việc submit task khỏi cơ chế thực thi.
Lợi ích:
- tái sử dụng thread (giảm overhead tạo thread)
- số thread cố định (tránh OutOfMemoryError)
- task queue (xử lý burst)
- lifecycle management (shutdown, awaitTermination). Methods:
execute(Runnable)(fire-and-forget),submit(Callable)trả Future. Tạo thread thủ công: khó quản lý, tốn kém hơn, khó test. ExecutorService là cách tiếp cận được khuyến nghị cho production code