global variables in multithreaded programming

Is there a way to avoid the use of global variables in a multithreaded c/c++ program since using global variables are bad practice?
Yes. Not declaring them.
how do I then deal with shared data among the different threads?
By passing pointers when the threads are created. As usual, all data that can be accessed asynchronously should be locked.
so I lock the pointers associated with the data item?
Last edited on
Not the pointer, the data itself.
Topic archived. No new replies allowed.