Saturday, June 26, 2010

What exactly happens when you have final values and inner classes in a method ?

Programmer Question

I have came across many situation where I needed to pass value to an other thread and I founded out that I could do it this way, but I have been wondering how is it working ?



public void method() {
final EventHandler handle = someReference;

Thread thread = new Thread() {
public void run() {
handle.onEvent();
}
};

thread.start();
}


Edit: Just realise my question wasn't exactly pointing toward what I wanted to know. It's more "how" it works rather then "why".



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails