2008/9/9 Charles Oliver Nutter <charles.nutter / sun.com>:
> Robert Klemme wrote:
>>
>> 2008/9/9 Mr_Tibs <tiberiu.motoc / gmail.com>:
>>>
>>> Darn it! It would seem like a good idea.
>>
>> I am not convinced yet.  Think about typical scenarios where one
>> thread creates tasks and hands them off to another thread. These will
>> break if every thread has its own idea of current dir.  If you use
>> absolute pathnames you do not need a local current dir.  This change
>> might even break existing code.  I believe we should at least
>> carefully evaluate consequences.
>
> There's no reason threads couldn't inherit a reference to their parent
> thread's cwd, only using a specific one if provided (reverting back to the
> parent's cwd afterward).

What does inheriting change about my argument?  Even with inheriting
you can send relative path names from one thread to another which do
not have the same cwd.  My point is, that since safe programming
requires either transferring absolute paths or relying on having a
single cwd per process (which is traditionally the case) there is
little need for this.

Granted, for the Dir.chdir idiom it is desirable to be thread safe.
But how often is this used in a multithreaded environment and does the
cost (implementation, complexity, risk) outweigh the benefits?

Your situation with JRuby is a bit different since all the JRuby
instances in a JVM share nothing (apart from classes maybe). But they
are rather like separate processes and having them all inside the same
JVM is more an optimization.

Kind regards

robert

-- 
use.inject do |as, often| as.you_can - without end