This could come down to a million different things.
1. Hardware
2. Compiler
3. Processor (ia64 vs x64)
4. How busy the system was at the time
5. Operating System
Thread one put message to queue (lock – put – unlock)
To be honest, that doesn't sound very efficient right from the start... So probably both runs are terribly slow.
Anyway, except hardware, probably the things that matter in this example most are:
1. quality of your OS process scheduler
2. quality of memory allocator in your C runtime libraries
@rapidcoder care to explain why that sounds inefficient? That gives an indication that he is locking only the minimal amount of code required to manipulate the container.
@rapidcoder of course he is locking access to the container, it's multi-threaded. Without locking he is subject to race conditions or unexpected behavior. Unless he is using only atomic operations (highly unlikely)
@rapidcoder of course he is locking access to the container, it's multi-threaded. Without locking he is subject to race conditions or unexpected behavior.
Yep, and that is slow. The faster is to use atomic operations or better use an immutable queue.