# Problem with rb\_thread\_create

**URL:** <https://www.ruby-forum.com/t/problem-with-rb-thread-create/197588>\
**Category:** Ruby\
**Created:** [October 16, 2010, 7:01pm UTC](https://www.ruby-forum.com/t/problem-with-rb-thread-create/197588 "2010-10-16T19:01:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![okkezSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Post date:** [October 16, 2010, 7:01pm UTC](https://www.ruby-forum.com/t/problem-with-rb-thread-create/197588/1 "2010-10-16T19:01:08Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Hi,

I have a small problem with rb\_thread\_create

first some example code:

========================================================================  
static VALUE sSysServerThreadInit(MQ\_PTR data)  
{  
MqSysServerThreadMain((struct MqSysServerThreadMainS\*)data);  
return rb\_last\_status\_get();  
}

# static VALUE SysServerThreadCall (VALUE data) { struct timeval sleep = {0, 200000}; VALUE ret = rb\_thread\_create(sSysServerThreadInit, VAL2PTR(data)); rb\_thread\_wait\_for(sleep); return ret; }

the problem is that it is not guaranteed that “rb\_thread\_create” will  
call the thread initialization code “sSysServerThreadInit”.  
I need a sleep for at least “200000” usec after the “rb\_thread\_create”.  
I think it is not good to have a fix waiting time because this is  
system or processor dependent.

question:

why does the “rb\_thread\_create” not call the “sSysServerThreadInit”  
proper?

thanks for help

mfg, Andreas O.  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v2.0.15 (GNU/Linux)  
Comment: Using GnuPG with SUSE - [http://enigmail.mozdev.org/](http://enigmail.mozdev.org/)

iQEcBAEBAgAGBQJMudgHAAoJEGTcPijNG3/AoB4IAJc0gLb5ymM6DbAg/KXZaOH6  
6TtITnodkd/bTSfLtN/s9giqjFa1YJhZqYZH7ot0XVx2KIZiJid5M6hIRm0NQ0Pe  
YRypuQyWz89pQN583Y7SnQb0SkXf3y26ajZLVnxUp300/21F4oy+f7Csw0BabL4/  
EAKSdqdcEDdlV/mP/LGgi7l7FprPsjDMVjvxTkQlGEKqdIxSrm0NH5yFoa2UINeP  
GovwSOW3xHyTFN0JQkUcA+vlKiWSR/RrTnuoJlCcEvmzqc3Ru9OhWKRy10q36/Zf  
KX15KNnXt/KXSfNDU2XGTLCHHfCuf8ZivmS8RMXUv28XENsdL5GQbWJvnOEFtXs=  
=yGiN  
-----END PGP SIGNATURE-----
