PHP extension with thread

General discussion on PHP

PHP extension with thread

Postby simo4761 on Fri Dec 02, 2016 9:50 am

Hi all,

I do not know if I am in the good section. I developpe an extension php, and I would like I could use Linux pthread in my extension.
But I have a feeling that my thread do not work, I looked for the documentation on the Internet but I find no concrete example.
Must to use thread zts be activated? Here is my code :

Code: Select all
void *called_from_thread(void *num){
    php_printf(" print by thread");

    pthread_t inc_x_thread;
    int x = 0;

    if(pthread_create(&inc_x_thread, NULL, called_from_thread, &x)) {
        php_printf("Error creating thread");

    php_printf("This is main print");

    if(pthread_join(inc_x_thread, NULL)) {
        php_printf("Error joining thread");

When I execute my extension in php, I always obtain the same display, This is main print print by thread For me the normal behavior of thread would be to have displays different during refreshment of page.

Every help is welcome :)

Posts: 1
Joined: Fri Dec 02, 2016 9:41 am

Re: PHP extension with thread

Postby zvika on Sun Dec 04, 2016 11:02 am

I'm not sure what exposure you will get here with PHP extension devs.
Try a PHP internals mailing list, this is a PHP language development board.
Good luck!
Zvika Dror
Zend Support Team
User avatar
Zend Global Support
Posts: 991
Joined: Sun Dec 14, 2008 9:48 am

Return to PHP

Who is online

Users browsing this forum: No registered users and 1 guest