Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8556679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:24:27+00:00 2026-06-11T15:24:27+00:00

I am writing a multithreaded C++ program and wish to use a multithreaded C

  • 0

I am writing a multithreaded C++ program and wish to use a multithreaded C library.
This library expects me to use the native system methods to create it some worker threads and pass control to its run() function using code such as this:

void system_specific_thread_init();
#ifdef _WIN32
    DWORD WINAPI system_specific_thread_run( LPVOID unused )
    {
        library_run();
        return 0;
    }

    void system_specific_thread_init()
    {
        Createthread(NULL, 0, system_specific_thread_run, NULL, 0, NULL);
    }
#else
    void* system_specific_thread_run(void *unused)
    {
        library_run();
        return NULL;
    }

    void system_specific_thread_init()
    {
        pthread_t id;
        pthread_create(&id, NULL, system_specific_thread_run, NULL);
    }
#endif
system_specific_thread_init();

after which it will use the relevant native system mutex methods to other native system threads to call its functions while getting on with is own work.

However, I am using the C++11 <thread> library to create and manage all my threads. I wish to create the worker thread(s) with std::thread(library_run) and call the library functions from other such threads.

Is it safe to do this, or will the DS9K cause demons to fly out of my nose?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:24:28+00:00Added an answer on June 11, 2026 at 3:24 pm

    The C++ standard doesn’t specify how C++ threads interact with any other thread library, but in general I would expect a C++ implementation to use the underlying system thread library, so your usage should be safe.

    Being able to use a third-party library that uses the system thread library locking primitives is such a common use case that it should be expected to work (otherwise C++ threading support would be almost useless in lots of real-world situations). As Pete points out, anything involving thread handles/ids can be more tricky (but shouldn’t be required from reading your question).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a multithreaded program in java. I have written something like this
I'm writing a Java program involving a multithreaded worker pool of Process es. Each
I am writing a multithreaded Python program, in which I am firing off worker
I'm writing a multithreaded Java program where each thread potentially needs its standard output
I am writing a multithreaded client that uses an IO Completion Port. I create
I am writing a multithreaded program in which i am getting exception java.lang.IllegalThreadStateException .
I'm writing a multithreaded program, which would crash when a particular exception was thrown.
I'm writing some code for testing multithreaded programs (student homework--likely buggy), and want to
I'am writing a multi-threaded program in C. Before creating the threads, a global python
I have a multithreaded openCV program that uses 4 threads to do the following:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.