Click here to Skip to main content
15,867,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have 4 threads. in each thread, there is a For loop. each thread is filling data in an array using that loop. now i want to update a progress bar based on the work these 4 threads are doing. how to do it? i thot of putting a global variable but the problem in that is each thread works randomly and will update that variable randomly. so the progress bar will go back and forth.it wont be smooth.
Posted

1 solution

Each thread should increment the value of your global variable. Also, make sure to synchronize the access to such variable.
 
Share this answer
 
Comments
Member 9385302 28-Aug-12 1:09am    
the sync is the main problem as there is no particular order in which threads operate.how to do that? so based on how much that array has been filled, i need to update the progress bar.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900