Node.js - Worker Threads
How can you safely increment a shared counter in Node.js worker threads using
SharedArrayBuffer and Atomics?SharedArrayBuffer and Atomics?Atomics.add performs atomic addition safely across threads.sharedArray[0]++ are not atomic and can cause race conditions.Atomics.add(sharedArray, 0, 1) to increment the counter atomically. -> Option A15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions