Home > Back-end >  Even if use the call system () is blocked, but didn't also the way to realize multithreading to
Even if use the call system () is blocked, but didn't also the way to realize multithreading to

Time:03-30




Using multiple thread call system () command is to use sendxml this program to send the test. The XML, sendxml this program is the most simple TCP client send things,
Tests found that does not like other concurrent software of existing business logic bugs in high concurrency server is measured,

CodePudding user response:

 
#include
#include
#include
#include

Void test_send (int _nID)
{


For (int ii=0; Ii<30; Ii++)
{
System ("/home/demo/bin/sendxml test. The XML ");
}

}


Int main (void)
{

STD: : thread t1 (test_send, 1);
T1. Detach ();

STD: : thread t2 (test_send, 2);
T2. Detach ();

STD: : thread t3 (test_send, 3);
T3. Detach ();

STD: : thread t4 (test_send, 4);
T4. Detach ();

STD: : thread t5 (test_send, 4);
T5. Detach ();

STD: : thread t6 (test_send, 4);
T6. Detach ();

STD: : thread t7 has (test_send, 4);
T7 has the detach ();

STD: : thread t8 (test_send, 4);
T8. The join ();

return 0;
}








Code as above, the execution of ps - ef can see multiple processes running

CodePudding user response:

The read-only competition resources, there is no conflict,

CodePudding user response:

server is: how do you like defects, let you think of this test case can find bugs?
The other high concurrency this... 10 you really is too little, and can not meet the high concurrent conditions

CodePudding user response:

This is a thread for loop 30 times, is to change the state of a value, for example, concurrency is correction, others don't know what tools, they said to send two at a time, every time accurately detect this problem,
  • Related