2

Is it like if I "pass a message" between two objects and if they happened to be have been instantiated in different threads then the invoked method would still run in its object's thread?

AppleGrew
  • 9,302
  • 24
  • 80
  • 124

1 Answers1

2

Calling a method is resolved at compile time and the method can be expected to be present at run time. Message passing is resolved at run time and the receiver object does not need to understand how to handle the message.

The term "message passing" in Objective-C does not have anything to do with threading.

I found a good article about this topic here: http://iskren.info/reading/info/ObjC/reading/dynamite.html

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
  • Does that mean, in C++ if I mark a method as `virtual` then invoking that is technically 'message passing'? This would mean all method invocation in Java too is 'message passing'. – AppleGrew Jan 27 '12 at 04:31
  • No, because although `virtual` methods (in both C++ and Java) are called using "late binding", the compiler and runtime guarantee that there actually is a method at the other end of the call. In Objective-C, you can pass any message to any object and the object will either handle it or not. – Greg Hewgill Jan 27 '12 at 04:35