running of multiplr threads at the same time

i'm doing work on chat massenger and facing difficulty to run multiple threads at the same time.

here is the sample code.

void menu();
void groupChat();
void personalChat();

int main()
{
sf::Thread thread(&menu());
thread.launch();
}

void menu()
{
do
{
cout<<"P for group chat"<<endl;
cout<<"p for group chat"<<endl;
cout<<"Enter choice";

switch( choice )
{
case 'p':
sf::Thread thread(&gtoupChat);
thread.launch();
case 'g':
sf::Thread thread(&personalChat);
thread.launch();
}
}while( choice != 'p' choice != 'g' );
}

void groupChat()
{

};

void personalChat()
{

};

in my programm
after menu when he selects a choice, next display of menu wait the termination of the selected thread.
while i want to show menu right after when a menu is selected.
plz reply soon.
Last edited on
you don't need to run menu in a thread

you don't have any code, so what's the
problem?
closed account (o1vk4iN6)
Well one obvious problem is input, which thread gets the input if you have the menu continually running and checking input ? You don't really need threading for what you have right now, you just need something that determines what state you want and then go to it (group/personal/menu). That being said the standard library isn't that great for something like a messaging client, ie displaying what your typing and receiving a message. Would probably require operating system specific code to modify the console buffer.
Topic archived. No new replies allowed.