()
| 346 | } |
| 347 | |
| 348 | private void scheduleNext() { |
| 349 | if (!queue.isEmpty() && active.compareAndSet(false, true)) { |
| 350 | delegate.execute(() -> { |
| 351 | Runnable task = queue.poll(); |
| 352 | if (task != null) { |
| 353 | try { |
| 354 | task.run(); |
| 355 | } finally { |
| 356 | active.set(false); |
| 357 | scheduleNext(); |
| 358 | } |
| 359 | } else { |
| 360 | active.set(false); |
| 361 | } |
| 362 | }); |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | /** |
| 367 | * Prevents further task submission. |