I'm parsing files in a directory. Logically speaking, it's a task consisting of synchronized subtasks but I thought that would make it even more complex for me :-)
2010/2/24 Greg Brown <[email protected]> > Tasks are a great way to run a background process. I am wondering why are > you creating and starting them in a loop? Are you trying to execute more > than one? > > On Feb 24, 2010, at 8:19 AM, Mathias Versichele wrote: > > > Ok, this might be the most difficult question until now from me > (especially since I can't seem to fully understand synchronization). I'm > using a Task class to run a background task asynchronously, so that the UI > stays responsive and my activityMeter keeps me informed about the progress > of the task. The problem now is, that somewhere I do this: > > > > private Process process; > > > > ... > > > > for loop { > > > > process = new Process(...) > > process.execute(new TaskAdapter<String>(tl)); > > > > other code... > > } > > > > the Process class extends the Task class. If my for loop gets called only > once everything works perfect. Otherwise, though, the code keeps running and > the process variable gets re-initialized with every loop until finally only > the last run of the loop makes the process run completely (with my UI acting > accordingly). What do I have to do to make the code stop after the > process.execute() line ? I already tried the wait and notify methods, but > they gave me errors until I used the synchronized keyword. Then, however, > the processes run correctly but my UI freezes (indefinitely). > > > > I'm kind of stuck here... is using the Task class the right way to go or > are there better ways for running threads in the background keeping my UI > nice and healthy ? > > > > Regards > > > > -- > > Mathias Versichele > > Bio-ir milieutechnologie / Msc. geografie > > Oudburgstraat 16 > > 9240 Zele > > 0485/16.07.08 > > -- Mathias Versichele Bio-ir milieutechnologie / Msc. geografie Oudburgstraat 16 9240 Zele 0485/16.07.08
