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 3342904
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:53:36+00:00 2026-05-18T00:53:36+00:00

It was dictated to me taht my routine has to have a return value

  • 0

It was dictated to me taht my routine has to have a return value and it needs to be returned.

i.e :

int mySuperThread(void)

I start the thread and it does what it needs to do. The question being asked is how to continually restart the thread again and again and again to do its job while still being able to return an integer (which is generated thru the thread’s run…). Mind you, from my understanding, it is a requirement that i use the “return” call via the thread’s int return value.

Suggestions? I’m trying to figure out if there is some flag or functon that i’m missing that relates to pthreads that allows a thread to restart when it ends.

  • 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-18T00:53:36+00:00Added an answer on May 18, 2026 at 12:53 am

    To start with, if you are calling the above function with pthreads, you’re probably having some trouble. The signature of the function pointer passed to pthread_create must be void * functionname(void*), which is to say, it must be a function that takes a single, pointer to void argument and return a pointer to void.

    Fortunately, void* can be cast to and from int with relatively little pain, so your function’s return can look like:

    return (void*) 5;
    

    Getting that return value is a little more involved. You’re right in being confused about continuing the thread after the return; you can’t. What you want to do is join with the thread, which is just waiting until the thread returns. Once that’s done, you could restart the thread as you did before.

    pthread_t mythread;
    int result;
    while(1){
        pthread_create(&mythread, NULL, mySuperThread, NULL);
        pthread_join(mythread, &result);
        /* do something with result */
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a customer who has dictated that I use Dapper ORM, which I've
I have a List being returned from a daoTemplate.query() call, using a rowMapper .
I've been developing .net console applications using C# and have always just dictated what
I have a grid view which pulls through data dictated by a stored procedure.
I want to have a base class which dictates the alignment of the objects
I am going to have to implement some functionality to my application soon that
I have a naive question about OOP design patterns. This is over-architecture, but I
I've been working on my first iPad based project which has proven a massive
I just have a question on the following. I've got a 2D array of
I have a form in the sidebar of a drupal site I'm currently working

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.