Object «Threading»

This article is automatically translated from Russian by Google Translator.

Provides management of parallel threads.

Method

Description

joinThread

Waiting for the specified flow to complete.

killThread

Finishes the execution of the specified flow.

receiveMessage

Queries the received message.

sendMessage

Sends a message to the specified stream.

startThread

Runs the function passed as a parameter in a separate thread.

joinThread

Waiting for the specified flow to complete.

Syntax

JavaScript
JavaScript
Threading.joinThread("threadId");

As a parameter, it is necessary to specify thread id.

killThread

Finishes the execution of the specified flow.

Syntax

JavaScript
JavaScript
Threading.killThread("threadId");

The thread id must be specified as a parameter.

receiveMessage

Queries the received message.

Syntax

JavaScript
JavaScript
Threading.receiveMessage(wait);

If wait is true, it waits until a message arrives.

sendMessage

Sends a message to the specified stream.

Syntax

JavaScript
JavaScript
Threading.sendMessage("threadId", "message");

As parameters, it is necessary to specify thread id and message.

startThread

Runs the function passed as a parameter in a separate thread.

Warning! This creates a new copy for all global variables. So if the value of a variable change in one thread, it stays the same in another thread.

Syntax

JavaScript
JavaScript
Threading.startThread("newThreadId", "functionName");

As parameters, it is necessary to specify thread id and function.