Futures
David Chisnall’s philosophical insights into concurrent programming, from the technical article “Futures in Objective-C”:
In functional languages, you can often get concurrency for free by having a clever compiler, instead of a clever human. This is good, because clever humans are expensive. Clever compilers are too, but they’re easier to copy than clever humans.

Futures are an amazingly clever way to coordinate multithreaded applications. (Obviously, it doesn’t make sense in all cases, though.) The basic idea is: A method call starts a thread, but directly returns a handle to the calculation result. The returned object is a so-called “future”, a placeholder for the not-yet-calculated actual result. The calling thread continues execution, it is blocked only when it actually uses the future later.
Did you know Java 1.5 brings support for futures as well? Search for it on koders.com!
Wiki also has a bit on the topic of futures. There seem to be different levels of transparency at which futures can be built into a language (and Java is obviously not too good at it). Take a look at David’s article describing futures in Objective-C to gain an insight into how cool futures can be when the technology uses a sufficient amount of introspection.
The Smalltalk way is even more amazing (look at the very bottom of that article to see how easy it is to use). Very cool stuff! ![]()
Coole Idee, die Dinger. Macht es das wirklich schneller? Ich muss mir doch tendenziell mehr Sachen merken, außerdem müssen Races zwischen (mindestens) aufrufendem Thread und dem dem Methodenaufruf folgenden Code verhindert werden.
Schon richtig, Locking-Probleme verhindern kann man damit auch nicht. Es ist eher ein Koordinierungsmechanismus für Multithreading.
Wenn Du aber schon die ein oder andere Methode hast, die bereits so reentrant ist, dann kannst Du sie mit minimalem Aufwand parall ausführen, ohne erneut mit Threads und Locks hantieren zu müssen.
Und das allein ist es mir schon wert.
Klappt natürlich besser, wenn die Programmiersprache Message-Forwarding unterstützt, so wie Smalltalk (siehe Artikel) oder Ruby.