Task Executor

Java Spring Configuration Multithreading Public New



Consider the following Spring bean:

public class TaskExecutor {

    private int threadCount;
    private String threadNameTemplate;
    private AtomicInteger counter = new AtomicInteger();
    private ExecutorService executorService;

    public void init() {
        ThreadFactory threadFactory = (runnable) -> new Thread(threadNameTemplate + counter.incrementAndGet());
        executorService = Executors.newFixedThreadPool(threadCount, threadFactory);

Select all of the statements that are correct.

Properties injected with @Value may, among other sources, come from system properties and JVM arguments.
As the values of threadCount and threadNameTemplate are private and have no setters, they cannot be set by Spring.
Initialization will fail because the counter and executorService fields are not managed by Spring.
If a property named "thread.count" is not made available to Spring (i.e. through property files), the value of threadCount field will be 10.
The value of the field threadNameTemplate will always be set to the same value regardless of properties provided to Spring.