title: why i can't dispatch_release when dealloc object?
body: <p>Use gcd, do some async homework.
  When dealloc did call, at this line "<strong>dispatch_sync(_queue, ^{})</strong>", it was aways life in thread.</p>
  
  <p>here is example of code (use ARC).</p>
  
  <p>ThingWithAQueue:</p>
  
  <pre><code>- (void)dealloc
  {
      NSLog(@"Dealloc in Thing");
      dispatch_sync(_queue, ^{});//check the queue is safe
      dispatch_release(_queue);
      _queue = nil;
      NSLog(@"Dealloc in Thing, done");
  }
  
  - (void)will{
      NSLog(@"will test gcd ");
  }
  
  - (void)did{
      NSLog(@"did test gcd ");
  }
  
  - (void)addSomeWork1:(void(^)(void))work
  {
  
      if (!_queue)
          _queue = dispatch_queue_create("com.johsrl.ThingQueue", NULL);
  
  
      dispatch_async(_queue, ^{
          [self will];
          work();
          //Since I refer to self here, dealloc will not be run until after all blocks complete
          [self did];
          NSLog(@"Work is done: %@",self);
      });
  
  }
  </code></pre>
  
  <p>ViewController:</p>
  
  <pre><code>- (IBAction)test1:(id)sender {
  
      ThingWithAQueue *thing = [[ThingWithAQueue alloc] init];
  
      [thing addSomeWork1:^{sleep(1);}];
      [thing addSomeWork1:^{sleep(1);}];
      [thing addSomeWork1:^{sleep(1);}];
      [thing addSomeWork1:^{sleep(1);}];
      [thing addSomeWork1:^{sleep(1);}];
  
      NSLog(@"The view controller is done with test 1.");
  
  }
  </code></pre>
  
  <p>log:</p>
  
  <pre><code>2015-04-06 14:47:17.200 GCD[18524:3570041] The view controller is done with test 1.
  2015-04-06 14:47:17.200 GCD[18524:3570124] do will test gcd 
  2015-04-06 14:47:18.206 GCD[18524:3570124] do did test gcd 
  2015-04-06 14:47:18.206 GCD[18524:3570124] Work is done: &lt;ThingWithAQueue: 0x7b246660&gt;
  2015-04-06 14:47:18.207 GCD[18524:3570124] do will test gcd 
  2015-04-06 14:47:19.208 GCD[18524:3570124] do did test gcd 
  2015-04-06 14:47:19.209 GCD[18524:3570124] Work is done: &lt;ThingWithAQueue: 0x7b246660&gt;
  2015-04-06 14:47:19.209 GCD[18524:3570124] do will test gcd 
  2015-04-06 14:47:20.209 GCD[18524:3570124] do did test gcd 
  2015-04-06 14:47:20.210 GCD[18524:3570124] Work is done: &lt;ThingWithAQueue: 0x7b246660&gt;
  2015-04-06 14:47:20.210 GCD[18524:3570124] do will test gcd 
  2015-04-06 14:47:21.212 GCD[18524:3570124] do did test gcd 
  2015-04-06 14:47:21.212 GCD[18524:3570124] Work is done: &lt;ThingWithAQueue: 0x7b246660&gt;
  2015-04-06 14:47:21.212 GCD[18524:3570124] do will test gcd 
  2015-04-06 14:47:22.216 GCD[18524:3570124] do did test gcd 
  2015-04-06 14:47:22.216 GCD[18524:3570124] Work is done: &lt;ThingWithAQueue: 0x7b246660&gt;
  2015-04-06 14:47:22.216 GCD[18524:3570124] Dealloc in Thing
  </code></pre>
  
  <p>When i click "pause program exeuction" button on Xcode.
  the show:</p>
  
  <p><img src="https://i.stack.imgur.com/tC5t5.png" alt="enter image description here"></p>
  
  <p>if i remove the line "<strong>dispatch_sync(_queue, ^{});</strong>"</p>
  
  <p>or </p>
  
  <p>remove about self methods in GCD block (  <strong>[self did];</strong> &amp;   <strong>[self did];</strong> ),</p>
  
  <p>the code is ok. </p>
  
  <p>what's happen in <strong>dispatch_sync(_queue, ^{});</strong> on this thread queue.</p>
  
  <p>"dispatch_sync(_queue, ^{});" is a right way for check the queue is thread ?</p>