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