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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:39:00+00:00 2026-05-23T02:39:00+00:00

I use threads in C as follows: pthread_t thread; if (pthread_create (& thread, NULL,

  • 0

I use threads in C as follows:

pthread_t thread;
if (pthread_create (& thread, NULL, thread_func (in, out), NULL)! = 0)
{
  return -1;
}
// code goes further

So everything works, but the code after the announcement thread is executed only after the entire thread, but not immediately. How to make the thread started and along with him was the code further?

EDIT:
I meant that the code that I wrote after updating the flow begins to play only after the function thread_funts Completely work is over. I need to simultaneously work flow and the code after the update stream. For example:

static void * thread_func () 
{ 
    int i;
    for (i = 0; i!=40; i++)
    {
        __android_log_print(ANDROID_LOG_INFO, "SDL", "OK");
    }
} 

JNIEXPORT jint JNICALL Java_org_divenvrsk_android_hellondk_HelloNDK_work (JNIEnv * env, jobject obj, jbyteArray array) 
{ 
  pthread_t thread; 

  if (pthread_create (& thread, NULL, thread_func (), NULL)! = 0) 
  { 
    return -1; 
  } 
  __android_log_print(ANDROID_LOG_INFO, "SDL", "gggggggg");
} 

I get this:

06-11 20:01:20.951: INFO/SDL(5238): OK
06-11 20:01:20.951: INFO/SDL(5238): OK
06-11 20:01:20.951: INFO/SDL(5238): OK
06-11 20:01:20.951: INFO/SDL(5238): OK
06-11 20:01:20.951: INFO/SDL(5238): OK
06-11 20:01:20.951: INFO/SDL(5238): OK
06-11 20:01:20.951: INFO/SDL(5238): OK
06-11 20:01:20.951: INFO/SDL(5238): OK
06-11 20:01:20.951: INFO/SDL(5238): OK

Here 40 times OK

06-11 20:01:20.955: INFO/SDL(5238): gggggggg

Ie, first performed the entire thread and then a further code, and I need to satisfy simultaneously, and thread and the code after the announcement thread.
Ie it is necessary that happened somewhere like this:

06-11 20:01:20.951: INFO/SDL(5238): OK
06-11 20:01:20.955: INFO/SDL(5238): gggggggg
06-11 20:01:20.951: INFO/SDL(5238): OK
06-11 20:01:20.951: INFO/SDL(5238): OK
06-11 20:01:20.951: INFO/SDL(5238): OK
06-11 20:01:20.951: INFO/SDL(5238): OK
06-11 20:01:20.951: INFO/SDL(5238): OK
06-11 20:01:20.951: INFO/SDL(5238): OK
06-11 20:01:20.951: INFO/SDL(5238): OK
06-11 20:01:20.951: INFO/SDL(5238): OK

Here 40 times OK

  • 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-23T02:39:01+00:00Added an answer on May 23, 2026 at 2:39 am

    So you’re saying you’re starting a thread and that thread runs till completion before you’re ready for it to, and you want to better control that? Look into thread synchronization — tools such as semaphores and mutexes (which the pthreads library can help you with). Those are some of the tools used to allow threads to inter-operate in a more controlled manner.

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

Sidebar

Related Questions

I am learning Perl's multithreading. My code: use warnings; use threads; use threads::shared; $howmany
I am trying to use the code depicted in this thread How to check
How to decide whether to use threads or create separate process altogether in your
General tutorial or good resource on how to use threads in Python? When to
I need to work with array from several threads, so I use CRITICAL SECTION
I want to use Thread.VolatileWrite() (or an equivalent function) to change the value of
I wanted to use boost::thread in my program, but get the following compiler error
Is it possible to use BackGroundWorker thread in ASP.NET 2.0 for the following scenario,
I'm trying to use a Thread in a simple winform. I have a ListBox
I use the Action<object>.BeginInvoke() method, does this use the thread pool or not? I

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.