allowAutoSwitch: if false, then the thread will not be automatically interrupted anymore (i.e. automatic thread switching will be temporarily disabled). Calling n times sim.setThreadAutomaticSwitch(false) requires to call n times sim.setThreadAutomaticSwitch(true) to restore the initial behaviour.
forbidLevel: allows to set an auto switch forbid level: a level > 0 indicates that automatic thread interruption is disabled.
Best is to always use following to temporarily forbid automatic thread interruptions:
local initialForbidLevel=sim.setThreadAutomaticSwitch(false) -- forbid automatic thread switches
...
sim.setThreadAutomaticSwitch(initialForbidLevel) -- restore to initial state
|