Board index » Visual Studio » thread handler
|
bassline
|
thread handler
Visual Studio185
Hi all! First sorry about my poor english. I developping a server application which runs as a windows service. At the beginig I was some problem but they are now solved. Today I make a notice. I am looking through the log file which was created by my server. It shows that if I start a thread it always get the same id. To be more understable. I have a static class member function what we call now mainloop. The declaration is as follow: void mainloop(void* _ptr); This function is created by a class function namely: start(). In start I use _beginthread() to spawn the thread. I call this function (start) once during the service. Here comes the intresting observation. I always get back the same handler for the same thread function. So if i start my service then stop it then start again end stop and so on than I always will see that the mainloop thread has the same thread handler. Why is this? I thought that the thread id/handler(s) are unique systemwide And an other little question. _In beginthread I shall have the ability to control the stack size. If I want a bigger stack then the default 1MB then it works correctly. But If I want a smaller for exapmle 128KB then it not working. (It is just a srtong feeling because I base my opinion on empirical test to how many threads I can spawn. If I increase the stack size then I can spawn less threads. For example If I set the stack size to 10 MB then I can spawn about 196-198 threadand and if I set the stack size 128 kB than I still can spawn just about 2000 thread due to 2GB heap memory limit/proccess(like with default 1 MB stack size.)) Thans in advance: Nagyjano - |
