// number of times to create threads and gather their ids privatestaticfinalint ITERATIONCOUNT = 50;
// Threads constructed per iteration. ITERATIONCOUNT=50 and // THREADCOUNT=50 takes about one second on a sun Blade 1000 (2x750mhz) privatestaticfinalint THREADCOUNT = 50;
// The thread local storage object for holding per-thread ids privatestatic ThreadId id = new ThreadId();
// Holds the per-thread so main method thread can collect it. JMM // guarantees this is valid after this thread joins main method thread. privateint value;
// holds true corresponding to a used id value boolean check[] = newboolean[THREADCOUNT*ITERATIONCOUNT];
// the test threads
TestThreadId u[] = new TestThreadId[THREADCOUNT];
for (int i = 0; i < ITERATIONCOUNT; i++) { // Create and start the threads for (int t=0;t<THREADCOUNT;t++) {
u[t] = new TestThreadId();
u[t].start();
} // Join with each thread and get/check its id for (int t=0;t<THREADCOUNT;t++) { try {
u[t].join();
} catch (InterruptedException e) { thrownew RuntimeException( "TestThreadId: Failed with unexpected exception" + e);
} try { if (check[u[t].getIdValue()]) { thrownew RuntimeException( "TestThreadId: Failed with duplicated id: " +
u[t].getIdValue());
} else {
check[u[t].getIdValue()] = true;
}
} catch (Exception e) { thrownew RuntimeException( "TestThreadId: Failed with unexpected id value" + e);
}
}
}
} // main
} // TestThreadId
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.15Bemerkung:
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.