ºìÁªLinuxÃÅ»§
Linux°ïÖú

linuxÏ̱߳à³ÌÎÊÌâ

·¢²¼Ê±¼ä:2013-03-21 11:16:59À´Ô´:ºìÁª×÷Õß:speed9393
ÓÐABÁ½¸öỊ̈߳¬AÏ̸߳ºÔð»ñÈ¡ÊÓƵÒƶ¯Õì²â£¬BÏ̸߳ºÔðÊÓƵMJPEG±àÂ룬ABÖж¼ÓÐselect()º¯ÊýÅжÏÊÇ·ñÓÐÀ´×ÔÊÓƵÊäÈëͨµÀµÄÊý¾Ý£¬AÏß³ÌÖеIJÎÊýnum£¨ãÐÖµ£©ÊÇÒ»¸ö²»¶Ï±ä»¯µÄÕûÐͲÎÁ¿£¬BÏ̵߳Ĵ´½¨Óë·ñ£¬Òª¸ù¾ÝnumµÄÖµÀ´¾ö¶¨£¬±ÈÈçÈç¹ûnum´óÓÚ10¾Í´´½¨BỊ̈߳¬ÇëÎÊÔõôʵÏÖ£¿
ÎÒµÄ×ö·¨ÈçÏ£¬µ«ÊdzöÏÖÁËÎÊÌâ¡£
ÎÒ´ÓÐÂÉèÁ¢Ò»¸öÈ«¾Ö±äÁ¿num2£¬ÔÚAÏß³ÌÖн«num2=num£»È»ºóÔÚÖ÷½ø³ÌÖÐÀûÓÃnum2µÄÖµÅж¨ÊÇ·ñ´´½¨Ïß³ÌB¡£ÎÒÊÔÁËһϣ¬·¢ÏÖÕâºÍÏß³ÌǶÌ×ûʲôÇø±ð°¡£¿£¨ÎҼǵÃÏß³ÌÖ®¼ä²»ÄÜǶÌ×£©Ïß³ÌA»¹ÊÇÒâÍâÖÕÖ¹£¬Ìáʾselectº¯Êý³¬Ê±¡£Ïß³ÌÖ®¼ä²»ÊDz»ÄÜǶÌ×Âð£¿ÇëÎÊÓ¦¸ÃÔõô×ö°¡£¿
pthread_create(&APid, 0, AData,NULL);
while(1)
{
if(num2>5)//num2ÊǸö²»¶Ï±ä»¯µÄÖµ£¬num2==num
{
pthread_create(&BPid, 0, BData,NULL);
}
}
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 4 ÌõÆÀÂÛ

  1. zyy_hz ÓÚ 2013-05-31 11:43:08·¢±í:

    ÄãÄǸönumÊÇÈ«¾ÖµÄÂð£¿
    pthread_create(&APid, 0, AData,NULL);
    Äã´´½¨AÏ̵߳Äʱºòû´«²ÎÊý°¡£¡
    ÄãAÏß³ÌÊÇÔõô»ñÈ¡numÕâ¸öÖµµÄ°¡
    »¹ÓоÍÊÇ
    if(num2>5)//num2ÊǸö²»¶Ï±ä»¯µÄÖµ£¬num2==num
    {
    pthread_create(&BPid, 0, BData,NULL);
    }
    Õâ¸öÅжÏÊDz»ÊÇÓÐÎÊÌ⣬Äãnum2ÊÇ×Ô¶¯¼ÓµÄÂð£¬ÊÇʲôʱºò¼ÓµÄ¡£
    Èç¹ýnum2¶¼ÊÇСÓÚ5µÄ»°Õâ¸öwhile¾ÍÏ൱ÓÚËÀÑ­»·ÁË£¬»áÕ¼ÓúܸߵÄcpuµÄ¡£

  2. Quite_Night ÓÚ 2013-05-10 20:33:44·¢±í:

    ÈõÈõµÄÎÊÒ»¾ä£ºwhile(1)
    {
    if(num2>5)//num2ÊǸö²»¶Ï±ä»¯µÄÖµ£¬num2==num
    {
    pthread_create(&BPid, 0, BData,NULL);
    }
    }

    Õâ¸öÊDz»ÊÇÒ»Ö±´´½¨ÏÂÈ¥£¿

  3. haohu137 ÓÚ 2013-05-09 19:06:42·¢±í:

    ·¹ý£¬¿´¿´¡£

  4. PiOsnoae ÓÚ 2013-03-21 14:43:26·¢±í:

    Õâ1Ô²Ïֽ𲻺Ã׬߹