Java: New thread from ThreadFactory should use runnable

Java’s ThreadPoolExecutor and some factory methods from Executors allow to pass a custom ThreadFactory in order to create new Threads 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));

Hi @bjmi ,

Thank you for your suggestion.
We found it very relevant and we were able to generalize it to cover more cases. We created a ticket accordingly.

Regards,
Richard