title: BASH - multiple threads using the same variable
body: <p>Lets assume the following situation:</p>
  
  <pre><code>function add_to_list
  {
      thelist="$thelist $$"
  }
  
  for i in $(seq 1 100); do
      add_to_list&amp;
  done
  
  wait
  echo "The list: $thelist"
  </code></pre>
  
  <p>This obviously does not work as it should, because the threads are accessing the same variable - how should it be done properly</p>