Menu

- Learn
- Documentation
  - Language Reference
  - Library Reference
  - Command-line Reference
  - Feature Overview
  - Articles
- Downloads
- Packages
- Community
  - Blog
  - Orgs using D
  - Twitter
  - Calendar
  - Forums
  - IRC
  - Community Discord
  - Wiki
  - GitHub
  - Issues
  - Get involved
  - Contributors
  - Foundation
  - Security Team
  - Donate
  - Sponsors
- Resources
  - Tour
  - Books
  - Tutorials
  - Tools
  - Editors
  - IDEs
  - run.dlang.io
  - Visual D
  - Acknowledgments
  - D Style
  - Glossary
  - Sitemap

Search
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

# core.thread.threadgroup

The osthread module provides types used in threads modules.
License:
Distributed under the Boost Software License 1.0. (See accompanying file LICENSE)
Authors:
Sean Kelly, Walter Bright, Alex Rønne Petersen, Martin Nowak

Source core/thread/osthread.d

class `ThreadGroup`;
  This class is intended to simplify certain common programming techniques.
  final Thread `create`(void function() `fn`);
    Creates and starts a new Thread object that executes fn and adds it to the list of tracked threads.
    Parameters:

    void function() `fn` | The thread function.

    Returns:
    A reference to the newly created thread.
  final Thread `create`(void delegate() `dg`);
    Creates and starts a new Thread object that executes dg and adds it to the list of tracked threads.
    Parameters:

    void delegate() `dg` | The thread function.

    Returns:
    A reference to the newly created thread.
  final void `add`(Thread `t`);
    Add t to the list of tracked threads if it is not already being tracked.
    Parameters:

    Thread `t` | The thread to add.

    In t must not be null.

  final void `remove`(Thread `t`);
    Removes t from the list of tracked threads. No operation will be performed if t is not currently being tracked by this object.
    Parameters:

    Thread `t` | The thread to remove.

    In t must not be null.

  final int `opApply`(scope int delegate(ref Thread) `dg`);
    Operates on all threads currently tracked by this object.
  final void `joinAll`(bool `rethrow` = true);
    Iteratively joins all tracked threads. This function will block add, remove, and opApply until it completes.
    Parameters:

    bool `rethrow` | Rethrow any unhandled exception which may have caused the current thread to terminate.

    Throws:
    Any exception not handled by the joined threads.

Copyright © 1999-2022 by the D Language Foundation | Page generated by Ddoc on Sat Sep 10 10:03:45 2022