finished ex Z4
This commit is contained in:
@@ -30,16 +30,27 @@ public class Bidder implements Runnable {
|
||||
if (state == BIDDING) {
|
||||
Random rand = new Random();
|
||||
double addon = rand.nextDouble(500);
|
||||
double base = auctioneer.getMaximumBid().amount();
|
||||
Bid maximumBid = auctioneer.getMaximumBid();
|
||||
double base = maximumBid == null ? 0 : maximumBid.amount();
|
||||
lastBid = base + addon;
|
||||
auctioneer.placeBid(new Bid(this, lastBid));
|
||||
long minSleep = (long) (base * 10);
|
||||
try {
|
||||
Utils.randomSleep(100, 5000);
|
||||
Utils.randomSleep(minSleep, minSleep + 1000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else if (state == FINISHED) {
|
||||
break;
|
||||
} else {
|
||||
auctioneer.stateLock.lock();
|
||||
try {
|
||||
auctioneer.stateCond.await();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
auctioneer.stateLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user