Yogesh,
You’re allocating the stack for your worker thread off the main thread’s stack. As soon as your main thread attempts any other operations that require stack, it’ll overflow its stack.
You need to new() your work thread stack from the heap or allocate it statically in the global space before main.
Cheers,
Mike