Threads, mutex and multiple functions

I have two functions, lets call func1 and func2, two threads start_t1 and start_t2 and one mutex.

I want that the two functions run parallel and my question would be if I need to declare mutex for all used functions so 2 in my case or is one enough?
You need a mutex for most of the shared resource. This resource is usually a variable.

For a simple type variable (such as bool) there might not be a mutex needed if and only if it is write only in one thread and read only in all other.

So a mutex is attached to variable not a function.
Topic archived. No new replies allowed.