Throw an exception when objects are used on the wrong thread

Speed impact is <1% for all of the performance tests other than array property enumeration and adding standalone objects to a realm. Those two were around 10% slower, so I made a quick optimization pass and got both faster than they were before this change.

@alazier 
Perhaps remove this function since it is now only used in one other place.