Skip to main content

set_max_threads

set_max_threads(const integer value) -> void

Sets the maximum number of threads Aleph will use.

The new setting applies only to computations started after this call. Existing computations are unaffected. Calling set_max_threads(0) restores the system default (usually the number of available hardware threads).

Parameters

  • value: The maximum number of threads. Use 0 or a negative value to restore the system default (typically the number of available hardware threads).

Example


# Leave a bit of system resources available for other programs.
set_max_threads(available_threads() - 2)

# Restore the default.
set_max_threads(0)

See also:

  • max_threads
  • available_threads