Hi Vince,

good point, but at the moment this is not an issue, thanks to the
Global Interpreter Lock: only one Ruby thread is ever executed at the
same time.  While this is not a great situation, it will at least make
sure that such a problem will never occur.
http://en.wikipedia.org/wiki/Global_Interpreter_Lock

Elise

On Tue, Apr 26, 2011 at 7:48 AM, dot c. <dot.cyclone / gmail.com> wrote:
> I'm studying Ruby 1.9.2 source code. Some issues about simultaneity.
>
> Object.new will call following funtion to allocate space from heap:
> static VALUE  
> {
>  ʨ  >  Ш  ԩ
>  ũ> }
>
> #define NEWOBJ(obj,type) type *obj = (type*)rb_newobj()
>
> VALUE
> rb_newobj(void)
> {
>  ¨>   
>   
>  稢   墩
>  
>
>  
> }
>
> static VALUE
> rb_newobj_from_heap(rb_objspace_t *objspace)
> {
>   
>
>  ¨     >  ¨妦 >   
>  >  
>  
>
>   ũ
>  >
>  Ϩ䪩 ű>
>  
> }
>
>
>
> I doesn see any code(in rb_newobj_from_heap), which is to make sure
> only one thread can call the function rb_newobj at the same time in
> multi-threading.
> The issue found in many other places. It seems that there can be only
> one thread in Ruby. But class Thread can create another thread.
>
> x = Thread.new {
> for a in 1..999
> bject.new
> end
> }
> for b in 1..999
> bject.new
> End
>
> Please tell me if some other mechanism solve the simultaneity issue.
> Thanks Vince
>
> --
> Posted via http://www.ruby-forum.com/.
>