Skip to content

Commit

Permalink
exponential growths helps?
Browse files Browse the repository at this point in the history
  • Loading branch information
radioegor146 committed Feb 7, 2024
1 parent 1a4e1f7 commit 71711e1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public Exec(int delta) {

void doAdd() {
try {
Thread.sleep(200L);
Thread.sleep(2000L);
} catch (Exception ignored) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
import java.util.concurrent.TimeUnit;

public class Pool {
public static ThreadPoolExecutor tpe = new ThreadPoolExecutor(0, 1, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<>(1));
public static ThreadPoolExecutor tpe = new ThreadPoolExecutor(0, 1, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<>(1));
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public void run() throws Exception {
try {
Pool.tpe.submit(e2::doAdd);
try {
Thread.sleep(50L);
Thread.sleep(500L);
} catch (InterruptedException e) {
}
Pool.tpe.submit(() -> {
Expand All @@ -19,14 +19,14 @@ public void run() throws Exception {
Exec.i += ix;
});
try {
Thread.sleep(50L);
Thread.sleep(500L);
} catch (InterruptedException e) {
}
Pool.tpe.submit(e3::doAdd);
} catch (RejectedExecutionException e) {
Exec.i += 10;
}
Thread.sleep(300L);
Thread.sleep(3000L);
if (Exec.i == 30) {
// 1->4(+3,e2)->14(+10,catch)->16(+2,e1)->30(+14,ix)
System.out.println("PASS");
Expand Down

0 comments on commit 71711e1

Please sign in to comment.