title: Shared Variable Among Ruby Processes
body: <p>I have a Ruby program that loads up two very large yaml files, so I can get some speed-up by taking advantage of the multiple cores by forking off some processes. I've tried looking, but I'm having trouble figuring how, or even if, I can share variables in different processes.</p>
  
  <p>The following code is what I currently have:</p>
  
  <pre><code>@proteins = ""
  @decoyProteins = "" 
  
  fork do
    @proteins = YAML.load_file(database)
    exit
  end
  
  fork do
    @decoyProteins = YAML.load_file(database)
    exit
  end
  
  p @proteins["LVDK"]
  </code></pre>
  
  <p><code>P</code> displays nil though because of the fork.</p>
  
  <p>So is it possible to have the forked processes share the variables? And if so, how?</p>