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.
lockLevel: allows to set an auto switch lock level: a level > 0 indicates that automatic thread interruption is disabled.
Best is to always use following to temporarily lock automatic thread interruptions:
--lua
local initialLockLevel=sim.setThreadAutomaticSwitch(false) -- lock automatic thread switches
...
sim.setThreadAutomaticSwitch(initialLockLevel) -- restore to initial state
|