6 ms·
Always use Interlocked over a lock statement if you're just dealing with incrementing numbers. It's 1-line, faster and always safe. Author is mistaken for advoc
by manigandham 10y ago
Always use Interlocked over a lock statement if you're just dealing with incrementing numbers. It's 1-line, faster and always safe. Author is mistaken for advocating a lock in these situations.
Only need lock() and the full Monitor classes if there's more to be done within the locked statement.