Skip to content

kiwi.lang.Thread wait() and notify() Methods in Kiwi

Nikos Siatras edited this page Oct 4, 2022 · 26 revisions

1. Overview

In this tutorial, we'll look at one of the most fundamental mechanisms in Kiwi — thread synchronization. We'll first discuss some essential concurrency-related terms and methodologies. And we'll develop a simple application where we'll deal with concurrency issues, with the goal of better understanding wait() and notify().

2. Thread Synchronization in Kiwi

In a multithreaded environment, multiple threads might try to modify the same resource. Not managing threads properly will of course lead to consistency issues.

2.1 Guarded Blocks in Kiwi

One tool we can use to coordinate actions of multiple threads in Kiwi is guarded blocks. Such blocks keep a check for a particular condition before resuming the execution. With that in mind, we'll make use of the following:


We can better understand this from the following diagram depicting the life cycle of a Thread:

Home

Kiwi.DB

  • MySQL/MariaDB - Coming to v1.0.2

Kiwi.IO

Kiwi.lang

Kiwi.locale

Kiwi.time

Kiwi.util

Clone this wiki locally