This module introduces you to the concept of multitasking in Java.
Multithreading is the ability of a program or an operating system process to manage its use by more than one user at a time and to
manage multiple requests by the same user without having to have multiple copies of the program running in the computer.
, you can make more than one event occur at the same time in your program.
While this is of course possible in other languages, doing so in C, (a procedural programming language) is much more difficult than in Java.
Java builds multitasking considerations directly into its language keywords, and Java provides classes and interfaces that make multitasking a breeze.
In addition, Java provides a platform-independent way to implement multitasking.
In this module, you will learn the basic concepts of multitasking, including:
A metaphor for multiple threads
Problems involving multiple threads
You will learn about the Thread
How to create and start a thread
The thread life cycle
How a thread's priority determines when it runs
How to implement the run() method for a thread
We will dive into keywords built into the Java language to help manage threads, the most important one being synchronized.
We will explore these topics mostly through the use of a program called TownHall.
This program simulates a group of noisy citizens at a town hall meeting.
Each citizen will be implemented as a separate thread of control, spouting off opinions whenever possible.
Through synchronization, we will create an MC for this town hall event to ensure each citizen's comments are heard without being trampled on.
The basic example of a town hall application discussed in this module's lesson involves synchronization.
Below is a quiz question to get you in the correct frame of mind.