https://toitlang.org/ logo
Typically you create a mutex and then do operation...
# general
f
Typically you create a mutex and then do operations within
do
. Untested (since I'm on my phone):
Copy code
import monitor

main:
  mutex := monitor.Mutex
  shared-var := 0
  task::
    while true:
      mutex.do:
        shared-var++
        sleep --ms=100
      sleep --ms=20
  while true:
    mutex.do::
      shared-var--
      sleep --ms=20