NChan
November 9th, 2001, 08:48 AM
Hi!
I am new to threads and I have a couple of questions about basic things about threads. If you have something like this without any critical sections or any other kind of synchronous object around it, what will happen.
int x, y;
func(x, y);/* a function which takes these two variables and modifies them*/
cout<<x<<y;
Will there be any problems? Wouldn't each thread make a copy of x and y and use that? So, is a critical section really needed? If not, when should the critical sections be really needed?
Also, is there any good sites on the net with basic stuff about this?
Thanks a lot,
NC
I am new to threads and I have a couple of questions about basic things about threads. If you have something like this without any critical sections or any other kind of synchronous object around it, what will happen.
int x, y;
func(x, y);/* a function which takes these two variables and modifies them*/
cout<<x<<y;
Will there be any problems? Wouldn't each thread make a copy of x and y and use that? So, is a critical section really needed? If not, when should the critical sections be really needed?
Also, is there any good sites on the net with basic stuff about this?
Thanks a lot,
NC