🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Multithreading.

Started by
3 comments, last by Snowman 23 years, 11 months ago
Hey- How important is it that the client and server be running in different threads when they are both running on the same computer? I had originally planned to make things work this way, but have had some troubles with multithreading, so now I''m trying to decide if I should work through it or just let it be. Thanks in advance for any help! -Snowman
Advertisement
I''ve been told both. That you should avoid Multithreding as it''s unnecassary and that you should use multithreading to keep things seperate. Well a while back (like 4months) a bunch of people did a bunch of studying of commercial game with a program that displayed all current threads and there owners and stuff like that.

Anyhow it appears that *All* (That were examined) had at least 2 threads running at all times. Also some major games.. I think StarCraft but don''t quote me (Look for the thread) had something like 5 to 7 threads going at a time. So it seems that the big boys do it so why shouldn''t we?

I''m sure there''s a reason behind it I don''t know but if the guys making the money do it, I''d say it''s a safe bet to work that a way! ;-)

Hope things work out for you!
See ya,
Ben
__________________________Mencken's Law:"For every human problem, there is a neat, simple solution; and it's always wrong."
"Computers in the future may weigh no more than 1.5 tons."- Popular Mechanics, forecasting the relentless march of science in 1949
Avoid threads if you can! But sometimes you just can''t.

Imagine you implemented a client & server in the same thread...now do a simple recv from the client, and wait for eternity...
...but you can always use the WSA messaging events to prevent this...


I have little knowlegde on UDP (only used TCP so far).
Maybe it''s this UDP that needs a thread, because it doesn''t work with WSA messaging...?

In Java, if you want flickerless animation you have to have a minimum of two threads. Kind of a downer, but multithreading isn''t that bad in Java {plus anything multithreaded instantly becomes multiprocessor.}
There''s nothing wrong with using a seperate thread for the client and the server, especially if you are planning on making the game multiplayer. It can help keep the speed of the game from being tied to the framerate of the host. You could even run the server in a seperate process, just like it is for the rest of the clients and use a loopback ip (127.0.0.1) to connect to the server that is on the same machine. In this case, you wouldn''t have to deal with threads, just networking issues, though it would require that any computer your game runs on have the proper networking protocols installed, and would be, perhaps imperceptibly, slower. It would also probably use more memory.



Mark Fassett
Laughing Dragon Entertainment
http://www.laughing-dragon.com

This topic is closed to new replies.

Advertisement