title: Multithreading with shared_ptr
body: <p>I gos tuck in my simple multithreading application which I am using as a simple test bench. What I want to achieve is to modify value of one variable passed to multiple threads and after all are done read the result.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;memory&gt;
  #include &lt;thread&gt;
  #include &lt;mutex&gt;
  
  void updateValue(const std::shared_ptr&lt;int&gt;&amp; value);
  
  int main()
  {
      auto sp = std::make_shared&lt;int&gt;(0);
      std::thread incrementThread_1(updateValue,sp);
      std::thread incrementThread_2(updateValue,sp);
      incrementThread_1.join();
      incrementThread_2.join();
      std::cout &lt;&lt; *sp &lt;&lt; std::endl;
  }
  
  void updateValue(const std::shared_ptr&lt;int&gt;&amp; value)
  {
      std::mutex g_i_mutex;
      for(int i = 0; i&lt;100;i++)
      {
          std::unique_lock&lt;std::mutex&gt; lk(g_i_mutex);
          (*value)++;
          lk.unlock();
      }
  }
  </code></pre>
  
  <p>Currently it just crashes. I don't have any meaningful info in debug window, so it's also not helping. Can someone please tell me what I might did wrong?</p>
  
  <p>One thing to point out - <strong>I don't want to use global variables</strong>, because the functions originally are in different files.</p>