t1 = Thread.new { output = []; cmd = IO.popen( "dir /s u:\\", 'r' ); while cmd.gets output.push $_ end Thread.current["output"] = output } ... t1.join got = t1["output"] got.each{|line| puts line} #### use threads; @t = map{ threads->create( sub{ print threads->self->tid; sleep 60; print threads->self->tid; } ) or die "threads->create failed $^E" } 1 .. 1000; #### C:\test>maxthreads.pl 1 2 3 ... 116 118 117 threads->create failed Not enough storage is available to process this command at C:\test\maxthreads.pl li A thread exited while 120 threads were running. #### PERL_SET_CONTEXT(aTHX) PERL_SET_CONTEXT((aTHX = PL_sharedsv_space)) PERL_SET_CONTEXT((aTHX = caller_perl)) PERL_SET_CONTEXT(interp) PERL_SET_CONTEXT(aTHX) PERL_SET_CONTEXT(thread->interp) PERL_SET_CONTEXT(aTHX) PERL_SET_THX(t) PERL_SET_CONTEXT(t) PERL_SET_CONTEXT PERL_SET_INTERP(i) Perl_set_context((void*)t) cthread_set_data(cthread_self(), t) (PL_current_context = t) PERL_SET_THX(t) PERL_SET_CONTEXT(t) PERL_SET_CONTEXT(proto_perl);