I have a method as below:
// Main Class:
processRecords(ArrayList<String> records) {
Boolean isSuccess = false;
ProcessRecordThread thread = new ProcessRecordThread(records);
new Thread(thread).start();
return isSuccess;
}
// Thread class:
run() {
for (String record : records) {
try {
process(record);
} catch (Exception e) {
isSuccess = false;
}
}
}
I want my main class to wait for my thread to complete processing of all records and then return isSuccess
variable and continue with main class execution.