Hello,

I have been working on a multithreaded program, and am trying to pass in a value from user input. The problem I an encountering is that the program will not stop to ask for user input if I include the cin in the thread function. It will simply complete the program and goto the "Press any key when ready" message.

Whereas, if I include the cin in the main() function, it will stop, and ask for user input - but I do not know how to synchronize it so that I can use it in the thread function.

Here's a snippet of what I have in the thread function:
Code:
	
void egg_funct()
{

...

if(requestMutexOrSemaphore(EGG) == TRUE)
	{
		cout << "Enter Selection: ";
		cin >> selection;

	switch (selection)
	{
		case 1 ...
                                ...
	}
}
And the thread code:
Code:
egg_thread = CreateThread(
                NULL,
		0,
		(LPTHREAD_START_ROUTINE) egg_funct,
		(LPVOID) NULL,
		CREATE_SUSPENDED,	
		&eggID);
And in the main() I simply added a cin >> selection - which then causes the program to stop and ask for input. If the cin >> selection was not in the main() function, it'll perform as described above, complete and finish the program without asking for user input.

The ouput, however, with the cin >> selection added in the main() function is a bit quirky. It in fact asks for user input twice, and does nothing the second time.