Posts

Strange behaviour of std::thread in Visual Studio 2012

Today I came across some strange behaviour with the VS2012 implementation of std::thread. The created thread’s job was to access the XIMEA camera API, one method of thread creation worked ok, and another only half worked.

With the first mode the API could grab from multiple cameras as expected, while with the other it could only grab from one camera – grabbing from the second camera would always fail. To make things stranger the mode that worked required the passing of an un-used argument to the thread function!

Here is the mode that didn’t work:

And here is the mode that does work OK, notice the dummy argument that is passed but otherwise unused!

All very strange!