Effectively final
Steven Simpson
ss at comp.lancs.ac.uk
Wed Sep 14 12:49:29 PDT 2011
On 14/09/11 19:46, blackbelt1999 wrote:
> Is there not a fundamental difference between the original code and
> the new code, namely the original code creates a new thread of
> execution while the new code does not?
Neither version creates a new thread. The creation of a Runnable does
not imply the creation of a new thread.
> >> void foo(final Socket socket) {
> >> new Runnable() {
> >> boolean timedOut;
> >> public void run() {
> >> system.setTimeout(100, #{ timedOut = true; });
> >> socket.onData(#{ if (!timedOut) System.out.println("Got
> data"); });
> >> }
> >> }.run();
> >> }
More information about the lambda-dev
mailing list