What's the difference with single and multithreaded coding

#1chedibang1994Posted 4/26/2014 12:16:05 AM
Topic
---
My blade will tear you limb from limb, my eyes aren't as cold as my glare, my heart is black as my metal, I am fulgore mark 3, prepare yourself for devastation
#2crynryanPosted 4/26/2014 12:24:47 AM(edited)
Each thread on a processor (CPUs, GPUs, etc) can only do one process at a time. Each thread can run in parallel and do things at the same time as all the other threads. This way, you can have multiple things be computed at the same time and thus increase the maximum amount of calculations that can be done in an amount of time.

EDIT:

As for the complexity of multithreaded programming, data can't be accessed by multiple threads at the same time, so this data has to be "locked" until the thread using it is done with it. If it isn't locked, and the same data was accessed by multiple threads, it would result in a crash. Single threaded games don't have this problem, since all the main game runs on just one thread. Most engines (if not all) still use multiple threads to handle things like audio playing without you telling them to. But since most audio is "play and forget", you can just tell it what song/sound effect to play and the rest is done for you.
---
(>O_O)> <(o_o<)
(>O_O)> <(o_o<)
#3chedibang1994(Topic Creator)Posted 4/26/2014 12:22:24 AM
crynryan posted...
Each thread on a processor (CPUs, GPUs, etc) can only do one process at a time. Each thread can run in parallel and do things at the same time as all the other threads. This way, you can have multiple things be computed at the same time and thus increase the maximum amount of calculations that can be done in an amount of time.


Thanks dude!
---
My blade will tear you limb from limb, my eyes aren't as cold as my glare, my heart is black as my metal, I am fulgore mark 3, prepare yourself for devastation