嘿,我的代码中有这个功能:
public synchronized void finished()
{
howManyDone++;
log.append("Finished creating board "+this.howManyDone+"\n");
if(howManyDone == boards.length)
JOptionPane.showMessageDialog(log, "All Boards Were Created.","Attention",JOptionPane.WARNING_MESSAGE);
}
我想在 log.append 命令中添加 evrey 线程在 sec 中运行的数量。我试着做这个:
public synchronized void finished()
{
long start = System.nanoTime();
howManyDone++;
long end = System.nanoTime();
long estTime = end - start;
double seconds = (double)estTime/1000000000;
}
而不是像这样打印每次的秒数:
log.append("Finished creating board " +this.howManyDone+ " in "+seconds+"\n");
但是当秒数出现时我在日志中得到的数字是这样的:6.00E-7 等等......我做错了什么?
谢谢