Can you make a small complete program the compiles, executes and shows the problem.
Thread problems can be complex and require more than a few lines of code to resolve.
Be sure to wrap your code...