Java’s ThreadPoolExecutor
and some factory methods from Executors
allow to pass a custom ThreadFactory
in order to create new Thread
s from a given Runnable
.
It is important that the new Thread
is created with provided Runnable
otherwise the tasks submitted to the executor are never run.
Noncompliant Code
Executors.newCachedThreadPool(r -> new Thread(name));
Compilant Code
Executors.newCachedThreadPool(r -> new Thread(r, name));