You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Santosh Pathak <sp...@veritas.com> on 2003/05/14 10:45:00 UTC

Problem with Threads

Hi,

I am using APR library in my application.
Surprisingly arguments passed to a thread is not working.
When I went through the source code, I saw following piece of code for
thread creation.

apr_thread_create()
{
    (*new) = (apr_thread_t *)apr_palloc(pool, sizeof(apr_thread_t));

    (*new)->pool = pool;
    (*new)->data = data;
    (*new)->func = func;

	if (((*new)->td = (HANDLE)_beginthreadex(NULL, 0,
                        (unsigned int (APR_THREAD_FUNC
*)(void*))dummy_worker,
                        (*new), 0, &temp)) == 0) {

}


So this way, argument passed to _beginthreadex is "new" and NOT "data".
(which is passed argument to the thread)
Is this correct?


Even sample source code (TstAprRoutines) available on the site is not
working!!!
in the file aprthreads.cpp, in the function ExThreadFunc1(),
value of initialcount is garbled, when you run the program :)

I want to pass class reference to different threads, and what I am seeing in
the thread function, I am getting new thread handle as argument :(
Could you please explain me how to pass an argument to a thread with the
function apr_thread_create()?

Thanks in advance

- Santosh Pathak
  VERITAS Enterprise Administrator
  VERITAS Software