Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Concurrent Patterns and Best Practices

You're reading from   Concurrent Patterns and Best Practices Build scalable apps in Java with multithreading, synchronization and functional programming patterns

Arrow left icon
Product type Paperback
Published in Sep 2018
Publisher Packt
ISBN-13 9781788627900
Length 264 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Atul S. Khot Atul S. Khot
Author Profile Icon Atul S. Khot
Atul S. Khot
Arrow right icon
View More author details
Toc

Thread Pools

In this chapter, we will be looking at more patterns for staying away from explicit locking and state management. The theme is to let us focus on the business logic and the rest of the boilerplate of explicit thread creation and management handled by a framework.

This set of design patterns yields robust code as we reuse tried and tested, well-proven library code. We start with thread pooling as a major step toward focusing on our business logic as tasks. The pooling patterns give us a facility to run these tasks concurrently. 

Firstly, we will cover the need for thread pools and the notion of a task. A task is a manifestation of the command design pattern, decoupling the task definition from its execution. We then look at ExecutorService, the pooling facility given by Java's threading library. Blocking queues are...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime