Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Java Concurrency and Parallelism
  • Table Of Contents Toc
  • Feedback & Rating feedback
Java Concurrency and Parallelism

Java Concurrency and Parallelism

By : Jay Wang
5 (1)
close
close
Java Concurrency and Parallelism

Java Concurrency and Parallelism

5 (1)
By: Jay Wang

Overview of this book

If you’re a software developer, architect, or systems engineer, exploring Java’s concurrency utilities and synchronization in the cloud, this book is an essential resource. Tech visionary Jay Wang, with over three decades of experience transforming industry giants, brings unparalleled expertise to guide you through Java’s concurrency and parallel processing in cloud computing. This comprehensive book starts by establishing the foundational concepts of concurrency and parallelism, vital for cloud-native development, and gives you a complete overview, highlighting challenges and best practices. Wang expertly demonstrates Java’s role in big data, machine learning, microservices, and serverless computing, shedding light on how Java’s tools are effectively utilized in these domains. Complete with practical examples and insights, this book bridges theory with real-world applications, ensuring a holistic understanding of Java in cloud-based scenarios. You’ll navigate advanced topics, such as synchronizing Java’s concurrency with cloud auto-scaling and GPU computing, and be equipped with the skills and foresight to tackle upcoming trends in cloud technology. This book serves as your roadmap to innovation and excellence in Java cloud applications, giving you in-depth knowledge and hands-on practice for mastering Java in the cloud era.
Table of Contents (20 chapters)
close
close
Free Chapter
1
Part 1: Foundations of Java Concurrency and Parallelism in Cloud Computing
7
Part 2: Java's Concurrency in Specialized Domains
12
Part 3: Mastering Concurrency in the Cloud – The Final Frontier

Employing Future and Callable for result-bearing task execution

In Java, Future and Callable are used together to execute tasks asynchronously and obtain results at a later point in time:

  • Callable interface: A functional interface that represents a task capable of producing a result:
    • call(): This method encapsulates the task’s logic and returns the result
  • Future interface: This represents the eventual completion (or failure) of a Callable task and its associated result:
    • get(): This method retrieves the result, blocking if necessary until completion
    • isDone(): This method checks whether the task is finished
    • Submitting tasks: ExecutorService accepts Callables, returning Futures for tracking completion and results

Here is an example of Callable and Future interfaces:

ExecutorService executor = Executors.newFixedThreadPool(2);
Callable<Integer> task = () -> {
    // perform some computation
    return 42;
};
Future...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY