Implementing the ThreadFactory interface to generate custom threads

Factory pattern is a widely used design pattern in the object-oriented programming world. It is a creational pattern and its objective is to develop a class whose mission is to create objects of one or several classes. Then, when we want to create an object of one of those classes, we use the factory instead of using the new operator.

With this factory, we centralize the creation of objects, thereby gaining the advantage of easily changing the class of objects created or the way we create these objects, considering the limitations we have in creating objects with limited resources. For example, we can only have N objects of a type that has the ability to easily generate statistical ...

Get Java 9 Concurrency Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.