Цитата(Aellipsis @ 10.10.2011, 14:40 ) | | threadData.join() работает, только у меня было время выполнения run() меньше 1мс |
Так повтори все 1000 раз, а потом время подели на 1000
| Код | class ThreadRepeat { public ThreadRepeat(Runnable r, int n) { this.r = r; this.n = n; } public void run() { for(int i=0; i<n;i++) r.run(); } Runnable r; int n; }; int cnt = 1000; long start = System.currentTimeMillis(); Thread* thread1000 = new TreadRepeat(threadData, cnt); thread.start(); thread.join(); System.out.println("Execution time was "+(double)(System.currentTimeMillis() - start)/cnt/1000); //Время в секундах
|
|