Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
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
Java: High-Performance Apps with Java 9

You're reading from   Java: High-Performance Apps with Java 9 Boost your application's performance with the new features of Java 9

Arrow left icon
Product type Paperback
Published in Mar 2018
Publisher
ISBN-13 9781789130515
Length 194 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Mayur Ramgir Mayur Ramgir
Author Profile Icon Mayur Ramgir
Mayur Ramgir
Arrow right icon
View More author details
Toc

Thread Pools


In this section, we will look into the Executor interfaces and their implementations provided in the java.util.concurrent package. They encapsulate thread management and minimize the time an application developer spends on the writing code related to threads' life cycles.

There are three Executor interfaces defined in the java.util.concurrent package. The first is the base Executor interface has only one void execute(Runnable r) method in it. It basically replaces the following:

Runnable r = ...;
(new Thread(r)).start()

However, we can also avoid a new thread creation by getting it from a pool.

The second is the ExecutorService interface extends Executor and adds the following groups of methods that manage the life cycle of the worker threads and of the executor itself:

  • submit(): Place in the queue for the execution of an object of the interface Runnable or interface Callable (allows the worker thread to return a value); return object of Future interface, which can be used to access...

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
Banner background image