#MaxThreads

Sets the maximum number of simultaneous threads.

#MaxThreads Value

Parameters

Value

The maximum total number of threads that can exist simultaneously. Specifying a number higher than 255 is the same as specifying 255 (in versions prior to 1.0.48, the limit was 20).

Remarks

This setting is global, meaning that it needs to be specified only once (anywhere in the script) to affect the behavior of the entire script.

Although a value of 1 is allowed, it is not recommended because it would prevent new hotkeys from launching whenever the script is displaying a message box or other dialog. It would also prevent timers from running whenever another thread is sleeping or waiting.

Up to two of the following types of threads may be created even when #MaxThreads has been reached: A hotkey, hotstring, OnClipboardChange, or GUI event if the first line of its subroutine is ExitApp, Pause, Edit, Reload, KeyHistory, ListLines, ListVars, or ListHotkeys. Also, an OnExit thread will always launch regardless of how many threads exist.

If this setting is lower than #MaxThreadsPerHotkey, it effectively overrides that setting.

If this directive is unspecified in the script, it will behave as though set to 10.

Like other directives, #MaxThreads cannot be executed conditionally.

#MaxThreadsPerHotkey, Threads, #MaxHotkeysPerInterval, #HotkeyInterval, ListHotkeys, #MaxMem

Examples

Allows a maximum of 2 instead of 10 simultaneous threads.

#MaxThreads 2