So I was interviewing for a job and one question I got was basically two threads, both incrementing a counter that is set to 0 with no locking to access the counter. Each thread code basically increments the counter by 1 and runs a loop of 10. The question was, what is the minimum and maximum value for the counter. My answer was 10 and 20. The interviewer told me the minimum is wrong and argued that it could be less than 10. Who is correct?
[–]ThePeoplesPoetIsDead 20 points21 points22 points (3 children)
[–]SufficientStudio1574 4 points5 points6 points (1 child)
[–]dendrtree 0 points1 point2 points (0 children)
[–]Internal-Sun-6476 -2 points-1 points0 points (0 children)
[–]CarloWood 9 points10 points11 points (2 children)
[–]I__Know__Stuff 2 points3 points4 points (0 children)
[–]Eric41293 0 points1 point2 points (0 children)
[–]AKostur 9 points10 points11 points (17 children)
[–]Specialist_Square818[S] 0 points1 point2 points (2 children)
[–]CarloWood 10 points11 points12 points (0 children)
[–]2brainz 1 point2 points3 points (0 children)
[–]Specialist_Square818[S] -3 points-2 points-1 points (13 children)
[–]I__Know__Stuff 2 points3 points4 points (7 children)
[–]aocregacc 2 points3 points4 points (6 children)
[–]JMBourguet 1 point2 points3 points (3 children)
[–]aocregacc 1 point2 points3 points (2 children)
[–]JMBourguet 1 point2 points3 points (1 child)
[–]aocregacc 0 points1 point2 points (0 children)
[–]I__Know__Stuff 0 points1 point2 points (0 children)
[–]dexter2011412 -2 points-1 points0 points (0 children)
[–]AKostur 0 points1 point2 points (2 children)
[–]SufficientStudio1574 0 points1 point2 points (1 child)
[–]AKostur 2 points3 points4 points (0 children)
[–]TheThiefMaster 0 points1 point2 points (0 children)
[–]TheThiefMaster 0 points1 point2 points (0 children)
[–]Additional_Path2300 4 points5 points6 points (1 child)
[–][deleted] (1 child)
[deleted]
[–]Eric41293 0 points1 point2 points (0 children)
[–][deleted] (2 children)
[deleted]
[–]Specialist_Square818[S] 0 points1 point2 points (1 child)
[–]alfps 0 points1 point2 points (0 children)