Confused between locking shared resources and Threads running in parallel

So first I learned that with creating a new thread, we can run the program in parallel...then I learned there are shared resources like Console that we should lock it down so until one thread is not done yet, another thread won't enter. So isn't this in conflict with Parallel threading? Doesn't it go back to a Sync app ?

Upvotes: 0

Views: 625

Answers (1)

cost
cost

Reputation: 4480

You only need to lock specific resources that aren't thread safe. I highly suggest you take a look at this five part article on multithreaded programming. The second part, Synchronization, talks about locking. Give the whole thing a read, it's very informative.

Upvotes: 1

Related Questions