How to print out contents to a file from two or more threads for two sections?
Posted on 2011-10-09
I have a thread implementing the run method. I have two entities payrollDept and hrDept with a superclass Department.
I have another class which passes in the startCounter and endCounter for each thread
//processing 100 objects with 6 threads as an example
// I divide the 100 payroll and hrdept objects by 6 threads
//creating each runner object with a start counter and end counter here
writer.writeHeader("Creating report for failures with payroll and Hrdept");
TestRunner(int startC, int endC, List <payrollDept> lst1, List<HrDept> lst2);
writer.writeFooter(" Completed payroll and Hrdept");
TestRunner (int startCounter, int endCounter, List<payrollDept> lst1, List<Hrdept> lst2)
For (int i=startCounter; i<=endCounter;i++)
processListAttribute(Department dpt, writer wt)
// perform some business logic here
My question is that I want to write failures with payrollDept and with HrDept to the file. I also want to create a header each for payrollDept and HrDept in the report file. What would be the best way to design a solution for this problem?