SElib.interpretInNewThread()
syntax: |
SElib.interpretInNewThread(filename, codeToInterpret) |
where: |
filename - the name of a script file with ScriptEase code. Use null if not interpreting a file.
codeToInterpret - a string variable with one or more ScriptEase statements to interpret, if not using a file. If a file is being interpreted, the string is used as command line arguments for the script file being interpreted.
|
return: |
number - the ID of the thread containing the new instance of ScriptEase. Depending on the operating system, returns 0 or -1 on an error.
|
description: |
For Win32 and OS/2, that is, for operating systems that support multithreading. Not supported for operating systems that do not support multithreading, such as DOS and 16-bit Windows.
This method creates a new thread within the current ScriptEase process and interprets a script within that new thread. The new script runs independently of the currently executing thread. This method differs from SElib.interpret() in that the calling thread does not wait for the interpretation to finish and differs from SElib.spawn() in that the new thread runs in the same memory and process space as the currently running thread.
A script writer must ensure any synchronization among threads. ScriptEase data and globals are on a per-thread basis.
If the parameter filename is not null, then it is the name of a file to interpret, and the parameters, filename and codeToInterpret are parsed as if being command line parameters to a main() function.
If the parameter filename is null, then codeToInterpret is treated as JavaScript code, a string with ScriptEase statements, and is interpreted directly.
|
see: |
SElib.interpret(), SElib.spawn()
|
example: |
// See usage in threads.jse and httpd.jse |