No you can't pass parameters to the run() method. The signature tells you that (it has no parameters). Probably the easiest way to do this would be to use a purpose-built object that takes a parameter in the constructor and stores it in a final variable:
Once you do that - you have to be careful of the data integrity of the object you pass into the 'WorkingTask'. The data will now exist in two different threads so you have to make sure it is Thread Safe.
Joined: Nov 17, 2010
Thanks Steve for your reply!
I am handling a huge data in my calling class instance.....
If I create an instance of "toWorkWith" class (calling class) in "WorkingTask" called class and initialize it, this will bring whole data in the calling class instance to the called class and this will result in the redundant data in both the classes....this will even eat up a huge memory...
can you please share your thoughts on this.... or this is the only way I can do it?
You do not create a new instance of the Object you want to pass in. You pass in the reference and store it in a variable. You do not create redundant data - you create a new reference to the same data. The memory usage is minimal.