← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Design and implement a thread-safe counter in Go that supports concurrent increment and read operations. The counter must be safe for use by multiple goroutines without external synchronization. Provide two implementations: one using a sync.Mutex and another using sync/atomic operations. For each implementation, write a small test driver that launches 1000 goroutines, each incrementing the counter 1000 times, and then prints the final value. Discuss the performance and correctness trade-offs between the two approaches, and explain when you would prefer one over the other in a real NVIDIA system such as a GPU driver or CUDA runtime component.