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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:03:38+00:00 2026-05-11T17:03:38+00:00

pthread_create returns the value 251 without creating the thread. Does anyone know what the

  • 0

pthread_create returns the value 251 without creating the thread. Does anyone know what the problem is? Please help. The machine is a HP-UX.

I’m new to multi-threading.

   #include <stdio.h>
   #include <stdlib.h>
   #include <pthread.h>

   void *print_message_function( void *ptr );

   main()
   {
        pthread_t thread1, thread2;
        char *message1 = "Thread 1";
        char *message2 = "Thread 2";
        int  iret1, iret2;
        /* Create independent threads each of which will
         * execute function */

        iret1 = pthread_create( &thread1, NULL, print_message_function, (void*) message1);
        iret2 = pthread_create( &thread2, NULL, print_message_function, (void*) message2);

        /* Wait till threads are complete before
         * main continues. Unless we  */
        /* wait we run the risk of executing an
         * exit which will terminate   */
        /* the process and all threads before the
         * threads have completed.   */

        pthread_join( thread1, NULL);
        pthread_join( thread2, NULL);
        printf("Thread 1 returns: %d\n",iret1);
        printf("Thread 2 returns: %d\n",iret2);
        exit(0);
   }

   void *print_message_function( void *ptr )
   {
        char *message;
        message = (char *) ptr;
        printf("%s \n", message);
   }
  • 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-11T17:03:38+00:00Added an answer on May 11, 2026 at 5:03 pm

    Edit : On HP-UX11. pthread_create is failing with error 251: Function is not available.

    Check whether -lc comes before -lpthread in your link order.
    If this is the case, then the call would resolve to stub in C-library
    and could cause this error.


    Did you link with -lpthread?

    You should use errno.h to see what error 251 is on your system or this should give you a more detailled message :

    printf("%s\n", strerror(errno));
    

    Moreover, when using pthread, you should check for the return value of almost every call to pthread* (see the man of every function to check for possible error returned)

    For pthread_create, you have at least 2 possible errors (depending on your system and pthread implementation) :

    pthread_create() will fail if:

    [EAGAIN] The system lacked the necessary resources to create
    another thread, or the system-imposed limit on the
    total number of threads in a process
    [PTHREAD_THREADS_MAX] would be exceeded.

    [EINVAL] The value specified by attr is invalid.

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

Sidebar

Ask A Question

Stats

  • Questions 114k
  • Answers 114k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer From the top of my head: MyTextBox.Lines = GetAgentsDetails(writeDir).ToArray(); Ofcourse… May 11, 2026 at 10:13 pm
  • Editorial Team
    Editorial Team added an answer This was also discussed here on SO. i answered it… May 11, 2026 at 10:13 pm
  • Editorial Team
    Editorial Team added an answer The MultiFieldQueryParser class extends the QueryParser class. Perhaps you could… May 11, 2026 at 10:13 pm

Related Questions

From pthread_key_create manpage : An optional destructor function may be associated with each key
I have a question concerning this code which I want to run on QNX:
On my laptop with Intel Pentium dual-core processor T2370 (Acer Extensa) I ran a
How to implement posix threads in linux c++.The smme program when saved as .c
I am working on a project and trying to use pthread_cond_wait() and pthread_cond_signal() to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.