From: Robert Klemme Date: 2007-06-08T22:15:07+09:00 Subject: Re: What about a 'series' type? On 08.06.2007 14:27, Robert Dober wrote: > On 6/8/07, Robert Klemme wrote: >> On 07.06.2007 23:12, Robert Dober wrote: >> > On 6/7/07, Robert Klemme wrote: >> >> On 07.06.2007 21:41, Robert Dober wrote: >> >> > On 6/7/07, Robert Klemme wrote: >> >> > > > First of all thx for your time but I am not a quick learner :( > > Obviously I am (or rather was )missing something very basic and if I > understand correctly that very basic is that method_invocations are on > copies of the local data, in each thread, is this *really* true? Well > you already showed with an example. Even more fine granular: there is one copy of local variables /per invocation/ of a method. You can play a bit with this to see the effect: def recurse(i = 5) s = "#{Thread.current.inspect} #{i} " print s, "enter\n" recurse(i - 1) if i > 0 print s, "leave\n" end If you then do something like 2.times { Thread.new { recurse } } You'll notice how values for "enter" decrease nicely and increase for "leave" per thread. Internally Ruby has a stack that stores all local variables (including method arguments) and every time a method is invoked a new stack frame is put on the stack which stores all those values. This is basically how most popular programming languages work. > Hopefully I can put this into work tonight, gotta go back to work > here, hopefully this weeks Ruby Quiz will be boooring, please James ;) :-) Kind regards robert