5
Reply

Global/Public Variables in Multithreading

jaypee bacol

jaypee bacol

Dec 22 2009 10:29 PM
7k

Hi Nikki,
My thread has a function with parameters -> Process_GIF_Creation(p_outputFilePath, pstrDT, intDir); These 3 parameters are declared globally/publicly. My concern is that the possibility of having a conflict/problem of using these 3 variables since I am using multiple thread. I have just read an article thru internet, please see below.
Link -> http://www.codersource.net/csharp_tutorial_multithreading.html
"At first, if one wants to create a multi-threaded application an important point to be remembered is, a global variable, which is being accessed by different threads, can try to modify the same variable. This is a generic problem, which is solved using a mechanism called Synchronization of threads. Synchronization is nothing but the process of creating some set of rules to operate data or resources."

Base in my requirement, I need to use scychronization of threads? Please advise me which is recommended.
Thanks,
Jaypee

Answers (5)