<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?xml-stylesheet href="_c74_vig.xsl" type="text/xsl"?>
<vignette name="Javascript and Threading" package="Max">
<h1>Javascript and Threading</h1>
<p>
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.
</p>
<p>
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.
</p>
<p>
By default, the <o>js</o> 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.
</p>
<p>
<b>Note: Immediate mode has been deprecated as of Max version 6.0.</b>
</p>
</vignette>
