Happens-before relationship

With threads, there’s little that can be guaranteed. You can’t determine exactly when a particular method will start, pause, or resume its execution. You can’t guarantee the sequence in which multiple threads might execute. On the exam, you’ll be questioned on the correct, incorrect, or probable outcome of code that defines or works with threads. The Java language uses a happens-before relationship, which is when one task is guaranteed to happen before another in a multithreading environment. Figure below shows this relationship.

Last updated