From: Brian Candler Date: 2003-02-03T02:31:51+09:00 Subject: Re: Local variables & blocks > > At the moment 'count' is shared between the threads, but what if each thread > > got its own local copy of 'count', initialised to the value at the time the > > thread were started? This would stop threads interacting via shared local > > variables - probably a good thing :-) > > this is called fork, and ipc is neither fun nor portable. No, it's not fork: I meant cloning only the local variables (stack frame). There is no duplication of the objects they refer to. Taking your example, cut down: pool = JobPool.new Thread.new do ... pool << job # a mutator end This should work perfectly well. All the threads would start out with the same value of 'pool', pointing to the same JobPool object, which they could send messages to / mutate or whatever. It's just if they decided to change 'pool' to refer to a different object, nobody else's 'pool' variable would be affected. So all local variables are local to the thread. If you want to send messages to a sister thread, then keep a reference to a common object (that is, a normal object, not IPC) Am I making sense? Regards, Brian.