#define LISTEN_PORT (5580)
 
 #include "css.h"
-
-//---------------------------------------------------------------------------
-#ifndef WIN32
-void * RunWeb(void *)
-{
-sigset_t signalSet;
-sigfillset(&signalSet);
-pthread_sigmask(SIG_BLOCK, &signalSet, NULL);
-
-#else
-unsigned long WINAPI RunWeb(void *)
-{
-#endif
-while (1)
-    web->Run();
-return NULL;
-}
 //---------------------------------------------------------------------------
 WEB::WEB()
     : m_res(0),
 //---------------------------------------------------------------------------
 void WEB::Start()
 {
-#ifdef WIN32
-unsigned long pt;
-CreateThread(
-    NULL,   // pointer to thread security attributes
-    16384,  // initial thread stack size, in bytes
-    RunWeb, // pointer to thread function
-    NULL,   // argument for new thread
-    0,      // CREATE_SUSPENDED, // creation flags
-    &pt     // pointer to returned thread identifier
-   );
-#else
-pthread_create(&m_thread, NULL, RunWeb, NULL);
-#endif
+m_thread = std::jthread([this](auto token){ Run(std::move(token)); });
 }
 //---------------------------------------------------------------------------
 void WEB::PrepareNet()
 m_listenWebAddr = ip;
 }
 //---------------------------------------------------------------------------
-void WEB::Run()
+void WEB::Run(std::stop_token token) noexcept
 {
+sigset_t signalSet;
+sigfillset(&signalSet);
+pthread_sigmask(SIG_BLOCK, &signalSet, NULL);
+
 PrepareNet();
 char recvBuffer[4096];
-while (1)
+while (!token.stop_requested())
     {
     struct sockaddr_in outerAddr;