hi frenz.. i m making an application in which I m calling servlets from Swing applications. these servlets are talking to database and performing some operations. so far fine. these opeartions are time consuming.. so I thought of using SwingUtilities. invokelater(). but I want to get return values from these operations which will be taking place in runnable objects run method. compiler is saying these values should be final. but i want to use these values in other parts of the programs. i.e. after servlet is done with its work.. it returns a value... I want to work with that value...plz help if anybody have any idea. plz make sure reply is easy to understand coz i m not perfect. thanx
Take care : using SwingUtilities.invokeLater will cause your code to be executed on the event dispatching thread, I think it will be better if you create your on Thread...
I'm not sure to understand your needs concerning the objects that you want to deal with after your thread return, but maybe you should have a look on the consumer / producer sample in the Java tutoriel (Threads section)
You can also create a version of your variables for the new Thread to play with. For example:
If you want to actually modify a variable in your new Thread, then use it later in the mehod you started that Thread from it's another story, especially if you need the new Thread to complete it's task before you do. In your case it may be more appropriate to have a callback. For example:
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop