Operators and functions for working with threads (thread type) are described here.



thread = thread

Assignment operator.



The Lock function blocks access to the global resource (mutex). If it is already occupied by another thread, then the current thread is waiting for it to be released. The mutex must be freed using the Unlock function.

resume(thread th)

The resume function continues the work of the thread that was stopped by suspend function.

SetThreadData(obj o)

The SetThreadData function assigns a variable of type obj to the current thread. The value of the variable can be retrieved with the ThreadData function.

sleep(int duration)

The sleep function pauses the current thread for at least the duration, in milliseconds.

suspend(thread th)

The suspend function suspends the th thread. Use the resume function to continue the thread.

terminate(thread th)

The terminate function terminates the thread. If the thread has already completed, the function does nothing.

ThreadData() obj

The ThreadData function returns the object that was assigned to the current thread. A variable of type obj is assigned to the thread by the function SetThreadData.


The Unlock function releases access to a global resource (mutex).

wait(thread th)

The wait function waits for the th thread to finish. If the thread has already finished, the function does nothing.


The WaitAll function waits when the WaitGroup counter becomes zero.

run {
  int count = 3
  for i in 1..count {
    go {
      // ...


The WaitDone function decreases the counter WaitGroup by one.

WaitGroup(int count)

The WaitGroup function creates a WaitGroup counter for the threads that should end with a calling the WaitDone function. count - the initial value of the counter.

Last updated