Re: Glib::Thread::create



On 29/04/2007 14:40, Norbert Bauer wrote:
> i would like to pass an argument (a pointer) to a thread (using Glib::Thread::create).
> In the class reference there is mentioned that i can do this using sigc::bind()
>
> Has anybody a short example for me how to do this or a link to an example?
>
> I'm working under windows and use Glibmm 2.4
>
>   

#include <glibmm/thread.h>
#include <iostream>
#include <string>

void thread_func(std::string s)
{
    std::cout << s;
    return;
}

int main(int, char**)
{
    Glib::thread_init();

    Glib::Thread *const my_thread = Glib::Thread::create(
        sigc::bind( sigc::ptr_fun(&thread_func), "Hello World" ), true);
       
    my_thread->join();

    return 0;
}


Regards
Niko




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]