I have a program that performs two different operations, and I would like to share variables between them.
At the moment, I use threads instead of fork processes, but I am having problems exchanging variables, even if I declare them unstable.
I tried using boost:
boost::thread collisions_thread2(boost::bind(function_thread2);
declaring the shared variables as volatile, but it seems the function_thread2 () function cannot see the changes in the shared variables.
What I would like to do is something like:
thread1:
while(true){
//..do somet stuff
check variable1
}
thread2:
while(true){
do some other stuff
check and write on variable1
}
Can you offer me a tutorial or method to easily exchange variables between threads? Maybe in this case the acceleration library can be useful? What do you think is best to use fork ()?
, , , .