C# Multithreaded Domain Design
Posted
by Thijs Cramer
on Stack Overflow
See other posts from Stack Overflow
or by Thijs Cramer
Published on 2010-04-07T08:49:32Z
Indexed on
2010/04/07
8:53 UTC
Read the original article
Hit count: 335
Let's say i have a Domain Model that im trying to make compatible with multithreading. The prototype domain is a game domain that consists of Space, SpaceObject, and Location objects. A SpaceObject has the Move method and Asteroid and Ship extend this object with specific properties for the object (Ship has a name and Asteroid has a color)
Let's say i want to make the Move method for each object run in a seperate thread. That would be stupid because with 10000 objects, i would have 10000 threads. What would be the best way to seperate the workload between cores/threads?
I'm trying to learn the basics of concurrency, and building a small game to prototype a lot of concepts.
What i've already done, is build a domain, and a threading model with a timer that launches events based on intervals. If the event occurs i want to update my entire model with the new locations of any SpaceObject. But i don't know how and when to launch new threads with workloads when the event occurs.
Some people at work told me that u can't update your core domain multithreaded, because you have to synch everything. But in that case i can't run my game on a dual quadcore server, because it would only use 1 CPU for the hardest tasks.
Anyone know what to do here?
© Stack Overflow or respective owner