[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

sessions and threads

dmatrix00d

7/6/2006 8:15:00 PM

Hi,

I forked off a thread using Thread.new. That thread is supposed to
change a session variable. When I check the session variable in the
thread's function, it had
changed inside the thread. However, this change does not persist after

the thread is finished.

Does anyone know why?

thanks

1 Answer

Timothy Goddard

7/6/2006 9:50:00 PM

0

Session variable? I take it this is on Rails?

Your original thread is probably ending the request and saving the
session before the other one can finish. You have to make the original
thread wait for the other one to finish using Thread.join.

Threads are very easy to make mistakes with. If you find tracking down
the cause of bugs like this hard, I wouldn't suggest using threads at
all without some further reading.

Erich Lin wrote:
> Hi,
>
> I forked off a thread using Thread.new. That thread is supposed to
> change a session variable. When I check the session variable in the
> thread's function, it had
> changed inside the thread. However, this change does not persist after
>
> the thread is finished.
>
> Does anyone know why?
>
> thanks