I need to time how long it takes to run each thread of an application I wrote, and I have finished and have a result, but don't really have any good way to verify that I did it right. I've never done anything like this before. If someone could give me a quick proofread it would be very helpful.
Here's the code creating the threads:
for (int i = 0; i < ROWS; i++) {
threads[threadCount] = new Thread(new TextDistanceThread("Macbeth.txt", "Othello.txt", i, 0));
threads[threadCount++].start();
threads[threadCount] = new Thread(new TextDistanceThread("Macbeth.txt", "HuckFinn.txt", i, 1));
threads[threadCount++].start();
threads[threadCount] = new Thread(new TextDistanceThread("Macbeth.txt", "TomSawyer.txt", i, 2));
threads[threadCount++].start();
threads[threadCount] = new Thread(new TextDistanceThread("Othello.txt", "HuckFinn.txt", i, 3));
threads[threadCount++].start();
threads[threadCount] = new Thread(new TextDistanceThread("Othello.txt", "TomSawyer.txt", i, 4));
threads[threadCount++].start();
threads[threadCount] = new Thread(new TextDistanceThread("TomSawyer.txt", "HuckFinn.txt", i, 5));
threads[threadCount++].start();
}
And the code for the thread itself:
public void run() {
long start = ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime();
//DO SOME STUFF
long end = ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime();
Driver.timeResults[0][row][col] = end - start;
Driver.results[row][col] = difference;
}