Home > Back-end >  Who knows Rad studio10.2 64 create a thread slow problem
Who knows Rad studio10.2 64 create a thread slow problem

Time:09-16

32-bit no problem, switching to a 64 - bit, with all kinds of way to create a thread is very slow, 100 threads require a minute or so,
(1) the CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) funs, NULL, 0, NULL);
(2) the _beginthread (funsss, 0, NULL);
(3) (HANDLE *) _beginthreadex (NULL, 0, fun, (void *) this, CREATE_SUSPENDED, NULL);
ResumeThread (threadHandle);
(4) the thread t (funss);
T.d etach ();
(5) * secondProcess TMyThread;
SecondProcess=new TMyThread (True);//Creation is suspended, the second process does not run yet.
SecondProcess - & gt; FreeOnTerminate=True;//Do not need to clean up after termination.
SecondProcess - & gt; Priority=tpLower;//Set the priority to the lower than normal.
SecondProcess - & gt; Resume ();//Now run the thread.


More than five ways to create a thread are tried, 32 bit fast, 3 seconds can create complete, but 64 will take at least a minute, who is a great god can answer why?


Use the compiler is rad studio 10.2

CodePudding user response:

Try using the Release mode, in the DEBUG mode, create a thread is a card

CodePudding user response:

The release version also not line,,,

reference 1st floor draculamx response:
try using the Release mode, in the DEBUG mode, create a thread is caton

CodePudding user response:

Does anyone know what the reason?

CodePudding user response:

Turn off the IDE, run exe file alone, look at the time, if not yet, put this code in the VC run inside the VC if no problem, that is the reason why CB, but CB don't feel strange, what's the problem,

CodePudding user response:

CB 10.2.1 bcc64 (7.30) measured without the original poster said:
 
#include
#include //2 by c + + Builder only
#include
#include

Struct AAA
{
int i=0;
Uintptr_t _handle;

//void Init () {_handle=_beginthread (Thread, 0, this); }
Void Init () {_handle=_beginthreadex (NULL, zero, the Thread, this CREATE_SUSPENDED, NULL); }
The static unsigned int __stdcall Thread (void * Args);
};

Unsigned int __stdcall AAA: : Thread (void * Args)
{
AAA * This=the Args (AAA *);

While (1)
{
Printf (" thread # % p - & gt; % d \ n ", (void *) This - & gt; _handle, This - & gt; i++);
Sleep (100);
}

return 0;
}

Int main ()
{
Triple a, b;

Anderson, nit ();
B.I nit ();
ResumeThread ((HANDLE) a. _handle);
Sleep (100);
ResumeThread ((HANDLE) b. _handle);

Getchar ();

return 0;
}

  • Related