Added in v2.0
Since version 2.0, TeSSH is completely multi-threaded. This has both advantages and disadvantages. The advantage of being multi-threaded is that TeSSH can run multiple scripts in parallel for improved performance and more advanced functionality. The disadvantage of being multi-threaded is that scripts which run in parallel need to be more careful about accessing or modifying global resources (such as variables).

In normal scripting and normal use, you will not notice any changes resulting from TeSSH being multi-threaded. By default, TeSSH will still execute commands, triggers, and other scripts in sequential order, just like in versions prior to 2.0.

However, certain "wait" commands can now be used to suspend the current thread, allowing it to wait in the background before continuing. When the thread continues at a later time, it will be running in parallel with any other commands, triggers, or scripts.

The commands that will cause a thread to suspend itself are: #WAIT, #WAITFOR, #WAITTHREAD, #WAITSIGNAL, and #SUSPEND. If you use any of these commands in your script, then you should make sure that the rest of the script following the wait command is "thread-safe".

To make a script "thread-safe", you should protect any access of a global resource, such as a global variable, using the #SECTION command. This will create a named "protected" section of code, and only one thread can execute a named section at a time.

Add comment

Login or register to post comments