T
Thorsten
Hi,
I have a lot of threads working parallel at my program. For time
measurements of some passages of the threads I take same timestamps on
an easy way like:
long t1 = System.currentTimeMillis();
System.out.println("something to do");
long t2 = System.currentTimeMillis();
System.out.println(t2-t1);
But there is a fault: assume I have 100 threads. One thread has just
printed "something to do" and the java vm "decides" to let all other
99 threads run, which takes 10 sec. Now t2 is calculated and has a
value which is 10 sec to high.
Is there a way to say for a thread that some code has to be executed
non-parallel? I think of something like:
atomic {
long t1 = System.currentTimeMillis();
System.out.println("something to do");
long t2 = System.currentTimeMillis();
System.out.println(t2-t1);
}
Does anyone have a hint ?
Regrads
Thorsten
I have a lot of threads working parallel at my program. For time
measurements of some passages of the threads I take same timestamps on
an easy way like:
long t1 = System.currentTimeMillis();
System.out.println("something to do");
long t2 = System.currentTimeMillis();
System.out.println(t2-t1);
But there is a fault: assume I have 100 threads. One thread has just
printed "something to do" and the java vm "decides" to let all other
99 threads run, which takes 10 sec. Now t2 is calculated and has a
value which is 10 sec to high.
Is there a way to say for a thread that some code has to be executed
non-parallel? I think of something like:
atomic {
long t1 = System.currentTimeMillis();
System.out.println("something to do");
long t2 = System.currentTimeMillis();
System.out.println(t2-t1);
}
Does anyone have a hint ?
Regrads
Thorsten