Thread:LOTRMod/@comment-25330335-20171021233524/@comment-25330335-20171022020726

When you start a program, everything in that program runs sequentially. For example (pseudocode...): print("Starting") loop(i, 1..5) { print(i) } This would print this: Starting 1 2 3 4 5 Say I want to print those characters, and do something that takes a lot of time with each of them (such as sending it to a database, or over a network). Suppose I do this: print("Starting") loop(i, 1..5) { print(i) send_to_database(i) } This code has to wait until that function (send_to_database) finishes before it can start the next time through the loop, and therefore takes quite some time to print all the numbers.

Multithreading is a good solution to this problem. Imagine if we could send that send_to_database to a different thread of execution, which still executes things sequentially, but does it in parallel with our loop, so that the output would be almost instantaneous, but our program would not finish until all of the parallel processes have finished. It means that our program would do the same amount of work, but it would distribute it over a number of different workers, so to speak, so that the overall execution time is much less. That's the basic concept, does that make sense?

That's why processors have cores, each core supports two virtual threads (managed by your OS) which can be used by programs in order to increase efficiency and decrease execution time. You can imagine why something like this would be taken advantage of in a situation like a game, where the amount of time taken for a certain thing to happen can be very important.