8241456: ThreadRunner shouldn't use Wicket for threads starting synchronization
Reviewed-by: dholmes, iignatyev
This commit is contained in:
parent
cf22d4440a
commit
a76f0f78ad
test/hotspot/jtreg/vmTestbase/nsk/share
@ -116,8 +116,8 @@ public class Wicket {
|
||||
public void waitFor() {
|
||||
long id = System.currentTimeMillis();
|
||||
|
||||
lock.lock();
|
||||
try {
|
||||
lock.lock();
|
||||
++waiters;
|
||||
if (debugOutput != null) {
|
||||
debugOutput.printf("Wicket %d %s: waitFor(). There are %d waiters totally now.\n", id, name, waiters);
|
||||
@ -172,8 +172,8 @@ public class Wicket {
|
||||
|
||||
long id = System.currentTimeMillis();
|
||||
|
||||
lock.lock();
|
||||
try {
|
||||
lock.lock();
|
||||
++waiters;
|
||||
if (debugOutput != null) {
|
||||
debugOutput.printf("Wicket %d %s: waitFor(). There are %d waiters totally now.\n", id, name, waiters);
|
||||
@ -209,8 +209,8 @@ public class Wicket {
|
||||
*/
|
||||
public void unlock() {
|
||||
|
||||
lock.lock();
|
||||
try {
|
||||
lock.lock();
|
||||
if (count == 0)
|
||||
throw new IllegalStateException("locks are already open");
|
||||
|
||||
@ -241,8 +241,8 @@ public class Wicket {
|
||||
debugOutput.printf("Wicket %s: unlockAll()\n", name);
|
||||
}
|
||||
|
||||
lock.lock();
|
||||
try {
|
||||
lock.lock();
|
||||
count = 0;
|
||||
condition.signalAll();
|
||||
} finally {
|
||||
@ -257,8 +257,9 @@ public class Wicket {
|
||||
* @return number of waiters
|
||||
*/
|
||||
public int getWaiters() {
|
||||
|
||||
lock.lock();
|
||||
try {
|
||||
lock.lock();
|
||||
if (debugOutput != null) {
|
||||
debugOutput.printf("Wicket %s: getWaiters()\n", name);
|
||||
}
|
||||
|
@ -22,7 +22,6 @@
|
||||
*/
|
||||
package nsk.share.runner;
|
||||
|
||||
import nsk.share.Wicket;
|
||||
import nsk.share.gc.OOMStress;
|
||||
import nsk.share.log.*;
|
||||
import nsk.share.test.Stresser;
|
||||
@ -45,7 +44,7 @@ public class ThreadsRunner implements MultiRunner, LogAware, RunParamsAware {
|
||||
private RunParams runParams;
|
||||
private List<Runnable> runnables = new ArrayList<Runnable>();
|
||||
private List<ManagedThread> threads = new ArrayList<ManagedThread>();
|
||||
private Wicket wicket = new Wicket();
|
||||
private AtomicInteger notStarted;
|
||||
private AtomicInteger finished;
|
||||
private boolean started = false;
|
||||
private boolean successful = true;
|
||||
@ -97,7 +96,10 @@ public class ThreadsRunner implements MultiRunner, LogAware, RunParamsAware {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
wicket.waitFor();
|
||||
notStarted.decrementAndGet();
|
||||
while (notStarted.get() != 0) {
|
||||
Thread.onSpinWait();
|
||||
}
|
||||
try {
|
||||
stresser.start(runParams.getIterations());
|
||||
while (!this.thread.isInterrupted() && stresser.iteration()) {
|
||||
@ -187,6 +189,7 @@ public class ThreadsRunner implements MultiRunner, LogAware, RunParamsAware {
|
||||
|
||||
private void create() {
|
||||
int threadCount = runnables.size();
|
||||
notStarted = new AtomicInteger(threadCount);
|
||||
finished = new AtomicInteger(threadCount);
|
||||
ManagedThreadFactory factory = ManagedThreadFactory.createFactory(runParams);
|
||||
for (int i = 0; i < threadCount; ++i) {
|
||||
@ -208,7 +211,6 @@ public class ThreadsRunner implements MultiRunner, LogAware, RunParamsAware {
|
||||
log.debug("Starting " + t);
|
||||
t.start();
|
||||
}
|
||||
wicket.unlock();
|
||||
started = true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user