• Home
    • View
    • Login
    This page
    • Normal
    • Export PDF
    • Export Word
    • Attachments
    • Page Information

    Loading...
  1. Dashboard
  2. Loom
  3. Main
  4. Structured Concurrency

Page History

Versions Compared

Old Version 42

changes.mady.by.user Alan Bateman

Saved on Mar 09, 2021

compared with

New Version 43

changes.mady.by.user Alan Bateman

Saved on Mar 09, 2021

  • Previous Change: Difference between versions 41 and 42
  • Next Change: Difference between versions 43 and 44
  • View Page History

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

There is no explicit support in the current prototype but it is possible to use existing constructs without needing too many new APIs. In particular, ExecutorService has been retrofitted to extend AutoCloseable so that it’s possible to write code like this and Executors has been updated to define a number of static factory methods that support usage in a structured manner.  Here's an example:

ThreadFactory factory = Thread.ofVirtual().factory()
try (ExecutorService executor = Executors.newThreadExecutor(factory)) {
    executor.submit(task1);
    executor.submit(task2);
}

A thread executing this code The thread that invokes Executors.newThreadExecutor is owner of the thread executor. It's the only thread can be call the shutdown, shutdownNow or close methods. The thread will block in the executor’s close method until the two tasks have have completed and executor has terminated.

...

Overview
Content Tools
ThemeBuilder

Terms of Use • License: GPLv2 • Privacy • Trademarks • Contact Us

Powered by a free Atlassian Confluence Open Source Project License granted to https://www.atlassian.com/software/views/opensource-community-additional-license-offer. Evaluate Confluence today.

  • Adaptavist ThemeBuilder Powered by Atlassian Confluence 7.4.13
  • Adaptavist ThemeBuilder printed.by.atlassian.confluence
  • Report a bug
  • Atlassian News
Atlassian
Adaptavist ThemeBuilder EngineAtlassian Confluence
{"serverDuration": 220, "requestCorrelationId": "7a263953e77041da"}