title: multiple threads vs reference counting: does each thread count variables separately
body: <p>I've been playing around with glib, which </p>
  
  <ol>
  <li>utilizes reference counting to manage memory for its objects;</li>
  <li>supports multiple threads.</li>
  </ol>
  
  <p>What I can't understand is how they play together. 
  Namely:</p>
  
  <ol>
  <li>In <code>glib</code> each thread doesn't seem to increase refcount of objects passed on its input, AFAIK (I'll call them thread-shared objects). Is it true? (or I've just failed to find the right piece of code?) Is it a common practice not to increase refcounts to thread-shared objects for each thread, that shares them, besides the main thread (responsible for refcounting them)?</li>
  <li>Still, each thread increases reference counts for the objects, dynamically created by itself. Should the programmer bother not to give the same names of variables in each thread in order to prevent collision of names and memory leaks? (E.g. on my picture, thread2 shouldn't crate a heap variable called output_object or it will collide with thread1's heap variable of the same name)? </li>
  </ol>
  
  <p>UPDATE: Answer to (question 2) is no, cause the visibility scope of
      those variables doesn't intersect:
      <a href="https://stackoverflow.com/questions/692636/is-dynamically-allocated-memory-heap-local-to-a-function-or-can-all-functions">Is dynamically allocated memory (heap), local to a function or can all functions in a thread have access to it even without passing pointer as an argument</a>.</p>
  
  <p>An illustration to my questions:</p>
  
  <p><img src="https://i.stack.imgur.com/aKnzt.png" alt="enter image description here"></p>