Skip to content

Commit 1b4e7d5

Browse files
Copilotrobfrank
andcommitted
Fix RandomTestMultiThreadsTest conversion - properly replace Thread[] with ExecutorService
Co-authored-by: robfrank <413587+robfrank@users.noreply.github.com>
1 parent 3444a0f commit 1b4e7d5

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

engine/src/test/java/com/arcadedb/RandomTestMultiThreadsTest.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public void testRandom() {
7373

7474
final long begin = System.currentTimeMillis();
7575

76+
try {
77+
7678
final ExecutorService executorService = Executors.newFixedThreadPool(WORKERS);
7779
final List<Future<?>> futures = new ArrayList<>();
7880

@@ -83,21 +85,21 @@ public void testRandom() {
8385
Future<?> future = executorService.submit(() -> {
8486
beginTransaction();
8587

86-
long totalTransactionInCurrentTx = 0;
88+
long totalTransactionInCurrentTx = 0;
8789

88-
while (true) {
89-
final long i1 = total.incrementAndGet();
90-
if (i1 >= CYCLES)
91-
break;
90+
while (true) {
91+
final long i = total.incrementAndGet();
92+
if (i >= CYCLES)
93+
break;
9294

93-
try {
94-
final int op = getRandom(100);
95-
if (i1 % 5000 == 0)
96-
LogManager.instance()
97-
.log(this, Level.FINE, "Operations %d/%d totalTransactionInCurrentTx=%d totalTransactions=%d (thread=%d)", i1,
98-
CYCLES, totalTransactionInCurrentTx, totalTransactionRecords.get(), threadId);
95+
try {
96+
final int op = getRandom(100);
97+
if (i % 5000 == 0)
98+
LogManager.instance()
99+
.log(this, Level.FINE, "Operations %d/%d totalTransactionInCurrentTx=%d totalTransactions=%d (thread=%d)", i,
100+
CYCLES, totalTransactionInCurrentTx, totalTransactionRecords.get(), threadId);
99101

100-
LogManager.instance().log(this, Level.FINE, "Operation %d %d/%d (thread=%d)", op, i1, CYCLES, threadId);
102+
LogManager.instance().log(this, Level.FINE, "Operation %d %d/%d (thread=%d)", op, i, CYCLES, threadId);
101103

102104
if (op >= 0 && op <= 19) {
103105
final int txOps = getRandom(10);
@@ -231,6 +233,7 @@ public void testRandom() {
231233
beginTransaction();
232234
}
233235
}
236+
}
234237

235238
try {
236239
database.commit();

0 commit comments

Comments
 (0)