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

  • Home
  • SEARCH
  • 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 6701211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:54:25+00:00 2026-05-26T06:54:25+00:00

I know mutex can be an implementation, however I’m wondering there would be a

  • 0

I know mutex can be an implementation, however I’m wondering there would be a way to pause/resume another thread as in video-playback. This approach is easier to program when the other running thread is complex.

  • 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-05-26T06:54:25+00:00Added an answer on May 26, 2026 at 6:54 am

    There’s SIGTSTP, a signal for pausing processes, which you could use if you have two processes, but signals have several drawbacks so I wouldn’t recommend using them. For a controlled, stable method you’d have to do it yourself using a mutex, where user pausing the playback leads to locking the mutex, and the thread doing the playback tries to lock the mutex . Like this:

    static pthread_mutex_t mutex;
    
    /* UI thread */
    void g(void)
    {
        while(1) {
            get_input();
            if(user_wants_to_pause)
                pthread_mutex_lock(&mutex);
            else if(user_wants_to_resume)
                pthread_mutex_unlock(&mutex);
        }
    }
    
    /* rendering thread */
    void f(void)
    {
        while(1) {
            pthread_mutex_lock(&mutex);
            /* if we get here, the user hasn't paused */
            pthread_mutex_unlock(&mutex);
            render_next_frame();
        }
    }
    

    If you need more communication between the two threads you could use the standard IPC mechanisms like pipes – you could then implement pausing and resuming based on that.

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

Sidebar

Related Questions

I was wondering if someone can tell me what would be the best way
I know that we can use pthread_mutex_init and pthread_mutex_lock to implement thread mutual exclusion.
Is there any way I can synchronize the data(data sharing) between C and Java
I started using boost::thread recently (WinXP, VS10, BoostPro) and found that mutex can be
I know that I can do something like $int = (int)99; //(int) has a
I know, I would have thought the answer was obviously no as well, but
There is an existing question regarding difference between Mutex and Critical section but it
I know, I know, the title of my message may seem provocative, since boost::mutex
How can I wait for a detached thread to finish in C++? I don't
Is there a way to implement a singleton object in C++ that is: Lazily

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.