title: Is unique_ptr thread safe?
body: <p>Is unique_ptr thread safe? Is it impossible for the code below to print same number twice?</p>
  
  <pre><code>#include &lt;memory&gt;
  #include &lt;string&gt;
  #include &lt;thread&gt;
  #include &lt;cstdio&gt;
  
  using namespace std;
  
  int main()
  {
      unique_ptr&lt;int&gt; work;
  
      thread t1([&amp;] {
          while (true) {
              const unique_ptr&lt;int&gt; localWork = move(work);
              if (localWork)
                  printf("thread1: %d\n", *localWork);
              this_thread::yield();
          }
      });
  
      thread t2([&amp;] {
          while (true) {
              const unique_ptr&lt;int&gt; localWork = move(work);
              if (localWork)
                  printf("thread2: %d\n", *localWork);
              this_thread::yield();
          }
      });
  
      for (int i = 0; ; i++) {
          work.reset(new int(i));
  
          while (work)
              this_thread::yield();
      }
  
      return 0;
  }
  </code></pre>