Skip to content

sud.createWorker ​

JS
    Worker sud.createWorker(string scriptPath)

Creates a worker thread.

Parameters

  • string scriptPath: Path of the worker entry file, relative to the worker source directory. The entry file must be located within the worker source directory or its subdirectories. If the worker source is configured as a specific file, the entry file must match the configured file.

Return Value

  • Worker: Returns a Worker object, described below.

Worker Description:

  • The maximum concurrent number of worker threads is limited to 1. Before creating the next one, call Worker.terminate() to end the current worker thread.
  • Code within a worker can only require files within the specified worker path; it cannot reference other paths.
  • The worker entry file is specified at createWorker() time; developers can dynamically specify the worker entry file.
  • The worker thread environment supports a limited set of SUD Runtime JavaScript APIs; see the specific APIs below.

Supported SUD Runtime JavaScript APIs

  • clearTimeout
  • clearInterval
  • require
  • setTimeout
  • setInterval
  • Worker.onMessage
  • Worker.postMessage