Java 9 Programming By Example by Peter Verhas
Author:Peter Verhas
Language: eng
Format: epub, azw3, mobi
Tags: COM051280 - COMPUTERS / Programming Languages / Java, COM051010 - COMPUTERS / Programming Languages / General, COM051300 - COMPUTERS / Programming / Algorithms
Publisher: Packt Publishing
Published: 2017-04-25T10:01:41+00:00
private void startAsynchronousGuessers(
IntervalGuesser[] guessers) {
executorService = Executors.newFixedThreadPool(nrThreads);
for (IntervalGuesser guesser : guessers) {
executorService.execute(guesser);
}
}
private void stopAsynchronousGuessers(
IntervalGuesser[] guessers) {
executorService.shutdown();
guessQueue.drainTo(new LinkedList<>());
}
The code is quite straightforward. The only thing that may need mention is that the queue of the guesses is drained into a collection that we do not use afterward. This is needed to help any IntervalGuesser that is waiting with a suggested guess in hand, trying to put it into the queue. When we drain the queue, the guesser thread returns from the method put in the guessQueue.put(guess); line in IntervalGuesser and can catch the interrupt. The rest of the code does not contain anything that would be radically different from what we have already seen and you can find it on GitHub.
The last question that we still want to discuss in this chapter is how much speed did we gain making the code parallel?
Download
Java 9 Programming By Example by Peter Verhas.azw3
Java 9 Programming By Example by Peter Verhas.mobi
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(11823)
Hello! Python by Anthony Briggs(9351)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9322)
The Mikado Method by Ola Ellnestam Daniel Brolund(9288)
Dependency Injection in .NET by Mark Seemann(8836)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(7836)
Grails in Action by Glen Smith Peter Ledbrook(7286)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7265)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7097)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(5933)
Kotlin in Action by Dmitry Jemerov(4617)
Practical Vim (for Kathryn Amaral) by Drew Neil(3718)
Cracking the GRE Premium Edition with 6 Practice Tests, 2015 (Graduate School Test Preparation) by Princeton Review(3582)
Linux Device Driver Development Cookbook by Rodolfo Giometti(3335)
Learn Windows PowerShell in a Month of Lunches by Don Jones(3224)
Learning Java by Patrick Niemeyer & Daniel Leuck(2861)
Learning React: Functional Web Development with React and Redux by Banks Alex & Porcello Eve(2822)
Mastering Java 9 by Dr. Edward Lavieri(2565)
Learning Concurrency in Python by Elliot Forbes(2540)