title: Realm accessed from incorrect thread
body: <p>I'm using serial GCD queue to work with realm. Application crashes with <code>Realm accessed from incorrect thread</code> exception when GCD starts to switch threads for the queue. Is there any way to bind given realm with a thread using GCD API?</p>
  
  <p>Here's a quick example</p>
  
  <pre><code>self.realmQueue = dispatch_queue_create("db", DISPATCH_QUEUE_SERIAL);
  
  __block RLMRealm *realm = nil;
  dispatch_async(self.realmQueue, ^{
      realm = [RLMRealm realmWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"temp"]];
  });
  
  self.motionManager = [[CMMotionManager alloc] init];
  self.motionManager.accelerometerUpdateInterval = 0.001;
  __block int i = 0;
  __block BOOL shouldBeginWriteTransaction = YES;
  
  [self.motionManager startAccelerometerUpdatesToQueue:[[NSOperationQueue alloc] init] withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) {
  
      dispatch_async(self.realmQueue, ^{
          if (shouldBeginWriteTransaction) {
              [realm beginWriteTransaction];
              shouldBeginWriteTransaction = NO;
          }
  
          AccelerationEvent *event = [[AccelerationEvent alloc] init];
          event.x = accelerometerData.acceleration.x;
          event.y = accelerometerData.acceleration.x;
          event.z = accelerometerData.acceleration.y;
          event.time = [NSDate date];
          [realm addObject:event];
  
          if (i % 1000) {
              dispatch_async(dispatch_get_main_queue(), ^{
                  self.xLabel.text = [NSString stringWithFormat:@"%f", event.x];
                  self.yLabel.text = [NSString stringWithFormat:@"%f", event.y];
                  self.zLabel.text = [NSString stringWithFormat:@"%f", event.z];
              });
          }
  
          if (i % 10000 == 0) {
              NSDate *startDate = [NSDate date];
              [realm commitWriteTransaction];
              NSLog(@"save time: %f", [[NSDate date] timeIntervalSinceDate:startDate]);
              shouldBeginWriteTransaction = YES;
          }
  
          i++;
      });
  }];
  </code></pre>