Skip to content

Commit

Permalink
refactor: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
stawirej committed Jan 3, 2024
1 parent dbc8434 commit a05eabe
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main/java/pl/amazingcode/threadscollider/ThreadsCollider.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ public void collide() {

try {

for (Action action : actions) {
for (int i = 0; i < action.times(); i++) {
executor.execute(() -> decorate(action));
}
}
startActions();

while (startedThreadsCount.get() < threadsCount)
;
Expand All @@ -76,6 +72,15 @@ public void collide() {
}
}

private void startActions() {

for (Action action : actions) {
for (int i = 0; i < action.times(); i++) {
executor.execute(() -> decorate(action));
}
}
}

private void decorate(Action action) {

try {
Expand Down

0 comments on commit a05eabe

Please sign in to comment.