# #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 MsgBox 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, the OnExit subroutine 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.

## Related

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

## Examples

#1

    #MaxThreads 2