forked from mtusi2026/mtusi2026lab2
24 lines
766 B
Java
24 lines
766 B
Java
package ru.mtusi.messenger.config;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.ThreadFactory;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
@Configuration
|
|
public class ExecutorConfig {
|
|
|
|
@Bean(destroyMethod = "shutdown")
|
|
public ExecutorService cacheEvictExecutor() {
|
|
AtomicInteger counter = new AtomicInteger();
|
|
ThreadFactory factory = r -> {
|
|
Thread t = new Thread(r, "cache-evict-" + counter.incrementAndGet());
|
|
t.setDaemon(true);
|
|
return t;
|
|
};
|
|
return Executors.newSingleThreadExecutor(factory);
|
|
}
|
|
} |