
This course includes our updated coding exercises so you can practice your skills as you learn.
See a demo
Explore the motivation for multithreading to boost responsiveness and performance through concurrency and parallel execution, and learn OS fundamentals—processes, threads, stacks, instruction pointer, and shared resources like files and heap.
Explore context switches, thread scheduling, and the trade-offs between multithreading and multiprocessing, including epochs and time slices, to optimize concurrency without starvation or security risks.
Create and run a multithreaded Java program using runnable and thread, start and name threads, set priorities, debug with breakpoints, and handle uncaught exceptions in a dedicated handler.
learn how to terminate threads safely using thread interrupt and daemon threads, including interrupt handling, isInterrupted checks, and when to use daemon threads to let apps exit.
Join threads to guarantee dependent work completes before use, avoiding busy waiting and race conditions. Use timeouts with thread join and safely collect results from parallel computations.
Define performance metrics for multithreaded applications, highlighting latency and throughput. Learn when breaking tasks into parallel subtasks reduces latency, and identify task types: inherently parallelizable, unbreakable, and partially breakable.
Explore a practical image recoloring algorithm in Java, compare single-threaded and multithreaded partitioning approaches, and analyze latency and performance scaling.
Explore the throughput performance metric and two approaches to improve it, including thread pooling with a fixed thread pool and a task queue to maximize resource utilization.
Build an HTTP server with a fixed thread pool to handle word-count searches in a large book, then measure throughput with J meter to optimize performance.
Java multithreading memory fundamentals summarize stack frames, per-thread local variables, and the heap, where objects and static data reside, while clarifying the difference between references and objects.
Learn how resources are shared between threads, why non-atomic operations on shared data produce inconsistent results, and how critical sections help manage these challenges.
Guard critical sections in Java multithreading to ensure atomic operations when threads share objects. Use synchronized methods or blocks with a lock object, understanding monitors and re-entrancy.
Identify which operations are atomic and use volatile to safely read and write long and double, then measure application performance with a metrics aggregation example.
Explore race conditions and data races in Java multithreading, identifying non-atomic shared resource operations and protecting them with synchronized blocks or volatile variables to ensure correct results.
Compare coarse-grained and fine-grained locking strategies for multiple shared resources and learn to prevent deadlocks by enforcing a consistent lock order across the code.
Discover the re-entrant lock, replacing the synchronized keyword with explicit lock and unlock control. Explore tryLock, lockInterruptible, fairness, and utilities like getQueuedThreads and getOwner to manage and test concurrent code.
Explore using a reentrant lock to synchronize a real-time javaFX dashboard that updates crypto prices across UI and background updater threads, using tryLock to avoid blocking and maintain responsiveness.
Learn to use a reentrant read write lock with separate read and write locks to enable concurrent reads, protect a binary search tree based inventory database, and increase read-intensive performance.
Explore the semaphore as a general synchronization tool, compare it with locks, and implement a scalable producer consumer pattern using a queue, empty and full semaphores, and a lock.
Explore inter-thread communication using condition variables, comparing semaphores, await, and signal, and signalAll with a producer-consumer example featuring a UI and authentication thread.
Learn to signal between threads with wait, notify and notifyAll on any object, using a thread-safe queue with back pressure in a producer-consumer matrix multiplication pipeline.
Explore lock-free programming with atomic operations to avoid deadlocks and priority inversion, using volatile variables and java.util.concurrent.atomic classes for thread-safe, non-blocking updates.
Use atomic integers to perform lock-free counting with atomic operations like increment, get, decrement, and add, solving race conditions in an e-commerce inventory counter without locks.
Build a lock-free stack using an atomic reference and compare-and-set, enabling thread-safe push and pop without locks. Compare its performance against a blocking stack to reveal speedups.
Explain blocking IO and IO bound applications, illustrating how CPU involvement, locks, and thread pools affect throughput, with scenarios like online stores and databases.
Explore non-blocking i/o as an alternative to the thread-per-task model for long i/o operations, enabling a thread-per-core approach with callbacks and improved stability, while noting readability and library challenges.
[Updated to 2023, including Project Loom and Virtual Threads]
Description
If you had your own jet plane, would you drive it to the grocery store or fly it on tour around the world?
Today every computer and phone comes with immense computing power and multiple cores, allowing full parallelism. In this course, you will go on a journey to learn all the fundamental tools you need to become a confident and successful multithreaded application developer. Using multithreading and concurrency, we will learn to get the most out of our computer to truly make it fly!
Teaching Philosophy
The course is designed to teach you "how to fish". Instead of memorizing classes, libraries, or Java APIs, we will learn the fundamentals of multithreaded programming, starting from the complete basics all the way to the very advanced topics in multithreading.
All lectures include the right theory and are accompanied by practical examples from relevant fields, such as:
User Interface applications
Image Processing
Web Applications
Computational programs
And others
It's a practical course that is meant to save you time. Instead of filling hours of material, I hand-picked the most important topics based on my practical experience.
Target Student for this Course
Students who already have some experience and basic knowledge in programming in Java.
Students who want to acquire multithreaded, parallel programming and concurrency skills in a short period of time.
Students who are interested in performance optimizations and getting a good foundation in the above-mentioned topics.
Students who want to take their careers to the next level. Whether you are a
Newly graduate and you're looking to land a dream job.
A professional engineer who wants to become a better programmer and improve your skillset.
A freelancer who wants to develop his/her own project and is looking to learn how to write efficient multithreaded code.
Then this course is for YOU!
Short Bio
My passion for multithreading and concurrency started in college, where I worked on a highly scalable, distributed B+ Tree research project sponsored by IBM.
Later I worked as a Computer Architecture Engineer at Intel Corporation and as a Software Engineer in other companies, where I developed many applications and features involving efficient and optimized multithreaded code to deliver real-time video, audio, and data - in education, healthcare, augmented reality, and Ad Tech.
Today I am a Principal Software Engineer and Software Architect. Training and mentoring engineers on all levels are both my job and my passion.
We will learn
Operating Systems fundamentals and motivation for multithreading and concurrency.
The basics of multithreading - how to create threads in Java and communicate between threads in Java.
Performance considerations and design patterns of multithreaded and parallel applications, optimizing for latency or throughput.
Data sharing between threads in Java, all the pitfalls and challenges, as well as the solutions and best practices.
Advanced lock-free algorithms and data structures for increased responsiveness and performance.
By the End of the Course
You will be able to
Write correct, responsive, and performant multithreaded applications in Java for any purpose and scale.
Apply best practices to architect multithreaded applications, algorithms, and libraries.
Become knowledgeable in concurrency & parallel programming, which will help you in job interviews, your daily work as an engineer, and your personal projects.
Become an expert in Java Multithreading, Concurrency, and Performance Optimization today!
FAQs
- "Will the course help me with interview questions?"
Yes! The course is focused on helping you become proficient in multithreading and concurrency in general and also master multithreading in Java in particular. You will learn all you need about threads in Java as well as common topics in interview questions involving locking, synchronization in Java, heap and stack memory organization, and so on. Although the course is not focused on interview questions specifically, and there's no way to predict what you will be asked during an interview question, the knowledge you will get will definitely set you apart from other candidates.
- "Does the course cover all threading classes and APIs in Java?"
"No. There are many books and expensive academic courses which cover EVERY single class and API which would take months to finish. In addition, Oracle provides excellent Java Docs that cover and explain every single Java multithreading API and class.
This course is different!
Based on years of experience in the field, I have carefully designed a short curriculum that teaches you all the essentials in a short amount of time.
No fillers! No more wasting time learning things you could read yourself in 5 minutes or don't ever need!
This course will build the foundation for becoming an expert in multithreading and concurrency. And also be able to successfully and easily extend your own knowledge in the future.
- "What if I don't understand something during the course and I have a question, what do I do?"
Not a problem! I am here to help you succeed! Multithreading is not an easy topic; no one is expected to get it all right away. Each lecture has a Q&A section where students can ask questions about the lecture or any follow-up questions about the topic in general. I will answer all the questions promptly and ensure you have all the tools for success.
- "Does the course cover interprocess communication and distributed Systems?"
No. Although those are really interesting and important topics that involve concurrency. They are not directly related to Java multithreading, which is the main topic of the course. We do mention those topics during the course, but they are out of scope and deserve their own course. The concepts, use cases, and challenges are very different than the ones we encounter while optimizing the performance of a single multithreaded Java application, algorithm, or library, so we will not cover them here.
- "Why do I need a separate course for concurrent programming?"
Concurrent programming is fundamentally different than transitional sequential programming. As in every engineering decision, there's always a tradeoff. Parallel and Concurrent programming can have a tremendous positive impact on the application's performance and responsiveness but it is a lot harder to get it right. In this course, we will learn all the caveats, techniques, and best practices to get the most out of multithreaded applications in Java.