A newer version of Max is available. Click here to access the latest version of this document.

Javascript and Threading

A thread is akin a continuously executing program running on a computer. Threads are managed by the computer’s operating system: the system is constantly pausing and resuming threads to create the effect of many simultaneous activities running on a single processor. For example, you can be downloading a song from the internet in one thread while reading your e-mail in another. When the Overdrive option is turned on, Max uses two threads and asks the operating system to ensure that one of the threads, which we call the high-priority thread, runs as regularly as possible (usually every millisecond). In exchange, Max tries to ensure that what happens in this thread uses as little of the computer’s time as possible. Time-consuming and user-interaction tasks are assigned to the low-priority thread.

The two threads allow you to use Max to do things that require high timing accuracy (such as MIDI) at the same time as you do things that are computationally expensive (such as decompress video) or involve user input.

By default, the js object executes all Javascript code in the low-priority thread. In particular, if it finds itself running in the high-priority thread, it will defer execution of whatever it was supposed to do to the low-priority thread.

Note: Immediate mode has been deprecated as of Max version 6.0.

See Also

Name Description
JavaScript Usage JavaScript Usage