From the course: Java Threads

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Making a thread to wait until another thread terminates

Making a thread to wait until another thread terminates - Java Tutorial

From the course: Java Threads

Making a thread to wait until another thread terminates

- Multithreading is all about threads executing tasks - Multithreading is all about threads executing tasks at the same time. But we cannot guarantee the order in which they execute because the thread scheduler decides it. For example, if you create and start three threads in a sequence, the thread scheduler doesn't start and end them in the specified order. Sometimes you'll need to make sure that threads execute in a particular order. Because threads access the same data concurrently Because threads access the same data concurrently and it could lead to synchronization issues. For instance, there could be one thread storing data in a variable and another thread running concurrently, reading that data. If the first thread hasn't finished storing the data before the other thread tries to read it, it's going to cause a problem. Threads need to communicate with each other. For example, a thread could request other threads…

Contents