10 years, 10 months ago.

Is it good to use global variables in running threads ?

Is it good to use global variables in running threads ?

1 Answer

10 years, 10 months ago.

Yes because it is a good way to communicate with other threads. Note however that the globals are shared among the threads and hence need synchronisation. A variable which is not used for communication should be local unless it is very large and consumes the entire stack of the thread.

Accepted Answer