/** * Both arguments and the return value are stored by the simulator. * * @param plus value loaded from XML * @param minus value loaded from XML */ @Override public synchronized LearnerGraph init( Collection<List<Label>> plus, Collection<List<Label>> minus) { LearnerGraph result = null, copyOfResult = null; // First, we call the expected method if (Thread.currentThread() == secondThread) { result = whatToCompareWith.init(plus, minus); copyOfResult = new LearnerGraph(result, result.config); iGraph = copyOfResult; } else { result = decoratedLearner.init(plus, minus); copyOfResult = new LearnerGraph(result, result.config); } syncOnCallOf(KIND_OF_METHOD.M_INIT); if (Thread.currentThread() != secondThread) { // second thread, checking. checkGraphEquality(iGraph, copyOfResult); iGraph = null; // reset stored data } syncOnCallOf(KIND_OF_METHOD.M_METHODEXIT); // aims to stop one of the threads running fast // from the first checkCall and overwriting the stored value before the other // thread had a chance to use it in a comparison. return result; }