Only data that is modified across the threads needs to be protected. I.e. when you add something to a vector (or any other container) in one thread and read from this vector in the other thread. Then the vector needs to be protected [with a mutex].
1.You can make some static public functions for the class.
2.Just split them away, think this problem in C way.
And please notice that when using multi-thread. Its memory space is seperated from the main and
1.You`ll need to re-allocate space for the known data to pass through call back correctly.
2.be ware of the run condition on the same resource.(You`ll need to lock the access to some variables or functions)
> fun1() only read some values and then draw some elements, but it cannot change anything.
But presumably it's reading things that fun2() writes to, which makes a complete nonsense of your bold assertion "and that have nothing in common." in your first post.
> And please notice that when using multi-thread. Its memory space is seperated from the main
Threads are typically "light-weight" and share the same virtual memory space (code and data). Threads have their own stacks, and perhaps thread local storage.
Processes are typically "heavy-weight" and have different virtual address spaces (even if you run the same program twice). Getting shared data between processes is far from trivial.