Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

dre-hh's Profile

GitHub User: dre-hh

Comments by

Avatar

This is not thread-safe at all. Mutating static scope is never threadsafe.

When asking what is thread-safe and what isn't it also depends on your application. In generall mutating shared state without a mutex, semaphore etc. is not threadsafe.

For Rails you have a seperate controller instance per web request thread. So mutating
controller instance vars and all the instance vars of the objects created by controllers is threadsafe, whereby mutating statics is not, because it is shared among all threads.

Rubyists hack around this with the Thread.current Hash