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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:48:21+00:00 2026-06-18T12:48:21+00:00

I have the following Main program: int main(int argc, char** argv) { /*checkParameters(argc,argv);*/ if

  • 0

I have the following Main program:

int main(int argc, char** argv) {

    /*checkParameters(argc,argv);*/

    if (pthread_create(&supplierid, NULL, &supplier, NULL) != 0);
        error("ERROR creating supply threads \n");

}

void *supplier () {

    printf("hello? \n"); 

    while (timeremaining >= 0) {


        printf("\n the stock is %d" , stock);
        printf("\n the supply ies %d", supply);

        timeremaining--;

        if (stock + supply > cap_max)
            stock = cap_max;
        else
            stock = stock + supply;

        sleep(0.1);
    }

    exit(EXIT_SUCCESS);
}

Ok well, 95% of the time I run this program I get Error creating supply thread. And it never prints hello.
This makes no sense. It just 1 thread.

thanks in advance.

  • 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-18T12:48:22+00:00Added an answer on June 18, 2026 at 12:48 pm

    You have a semicolon after your if statement:

    if (pthread_create(&supplierid, NULL, &supplier, NULL) != 0);
    

    This means that the statement that appears to be nested within the if statement is not actually nested at all and will always execute regardless of the condition. Specifically, C is interpreting your code to mean

    if (pthread_create(&supplierid, NULL, &supplier, NULL) != 0)
        ; /* Do nothing */
    
    error("ERROR creating supply threads \n");
    

    To fix this, remove the stray semicolon.

    Hope this helps!

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

Sidebar

Related Questions

I have the following program called Scorecommandline : int main (int argc, char *argv[])
I have the following program: int main(int argc, char *argv[]) { int a, b;
I have the following code: int main(int argc, char *argv[]) { if(strcmp(argv[1],-e)==0) { //perform
I have the following C code: int main(int argc, char *argv[]) { int n
I have following simple program: import std.stdio; int main(string[] argv) { writeln(Hello, world!); return
I have this C++ file: #include <iostream> int main(int argc, char *argv[]) { std::cout
I have the following code int main() { int a=6; void *p; p=&a; p++;
I have the following code in C++ here: #include <iostream> int main(int argc, const
So I have the following test code: #include <string.h> #include <stdio.h> int main(int argc,
Let's consider this simple test program: #include <stdio.h> #include <string.h> int main(int argc, char

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.