# 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.

![](https://3494582050-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LSemf7mp1liQa7nfIAC%2F-LgQvQB46iw6O09uUHGv%2F-LgQxHtJh5QuG2FLhLxj%2Fimage.png?alt=media\&token=ed49bb8a-6a22-410d-84a4-4610b541349d)



![](https://3494582050-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LSemf7mp1liQa7nfIAC%2F-LgQvQB46iw6O09uUHGv%2F-LgQxbX9FPWiRGhGL6DI%2Fimage.png?alt=media\&token=c441f6fc-f7d3-4622-bb1d-40cad0592150)
