PreemptProtect
PreemptProtect[expr] evaluates expr, without any interruption from preemptive evaluations.
Examples
Protect critical code:
PreemptProtect[
x = 1;
y = 2;
x + y
]Ensure atomic operations:
PreemptProtect[
counter++;
result = Process[counter]
]In parallel computing:
PreemptProtect[
AppendTo[sharedList, newValue]
]Please visit the official Wolfram Language Reference for more details.