Two threads are not work simultaneously

Hello,

I need to create two threads. Whan I do it, I get a warning message in the log:

LogStats:Warning: MetaData mismatch. Did you assign a stat to two groups? New //STATGROUP_Threads//FTCPSocketListeningTh///Thread_2130_0///####STATCAT_Advanced#### old //STATGROUP_Threads//FTCPSocketListeningTh///Thread_202c_0///####STATCAT_Advanced####

And my second thread dont stop opposed to in the first. I read in answers, it because of the threads same name, but I called it different.

Help me fix it. Thanks!

Template сode of my two almost identical FRunnable class: FServerStatusCheckingTh and FTCPSocketListeningTh
Threads just display a message in the log every second. Base on:

.h



#pragma once
 
 class SIENNACLIENTPROJECT_API FServerStatusCheckingTh : public FRunnable
 {
     static  FServerStatusCheckingTh* Runnable;
 
     FRunnableThread* Thread;
 
 public:
 
     FServerStatusCheckingTh();
     ~FServerStatusCheckingTh();
 
     virtual bool   Init();
     virtual uint32 Run();
     virtual void   Stop();
 
     static FServerStatusCheckingTh* RunServerChecking();
 
     static bool bThreadRun;
 
     static void Shutdown();
 
 };


.cpp


#include "SiennaClientProject.h"
 #include "ServerStatusCheckingTh.h"
 
 FServerStatusCheckingTh* FServerStatusCheckingTh::Runnable = NULL;
 bool FServerStatusCheckingTh::bThreadRun = false;
 
 FServerStatusCheckingTh::FServerStatusCheckingTh()
 {
     Thread = FRunnableThread::Create(this, TEXT("ServerStatusChecking"), 0, TPri_BelowNormal); 
 }
 
 FServerStatusCheckingTh::~FServerStatusCheckingTh()
 {
     delete Thread;
     Thread = NULL;
 }
 
 bool FServerStatusCheckingTh::Init()
 {
     bThreadRun = true;
     return true;
 }
 
 uint32 FServerStatusCheckingTh::Run()
 {
     while (bThreadRun)
     {
         FPlatformProcess::Sleep(1.f); 
     GLog->Log("FServerStatusCheckingTh");
         
     }
     return 0;
 }
 
 void FServerStatusCheckingTh::Stop()
 {
 }
 
 FServerStatusCheckingTh* FServerStatusCheckingTh::RunServerChecking()
 {
     if (!Runnable && FPlatformProcess::SupportsMultithreading())
     {
         Runnable = new FServerStatusCheckingTh();
     }
     return Runnable;
 }
 
 void FServerStatusCheckingTh::Shutdown()
 {
     if (Runnable)
     {
         bThreadRun = false;
 
         delete Runnable;
         Runnable = NULL;
     }
 }

.h


#pragma once
 
 class SIENNACLIENTPROJECT_API FTCPSocketListeningTh : public FRunnable
 {
     static FTCPSocketListeningTh* Runnable;
 
     FRunnableThread* Thread;
 
 public:
 
     FTCPSocketListeningTh();
     ~FTCPSocketListeningTh();
 
     virtual bool   Init();
     virtual uint32 Run();
     virtual void   Stop();
 
     static FTCPSocketListeningTh* RunSocketListening();
 
     static bool bThreadRun;
 
     static void Shutdown();
 
 };

.cpp


 #include "SiennaClientProject.h"
 #include "TCPSocketListeningTh.h"
 
 FTCPSocketListeningTh* FTCPSocketListeningTh::Runnable = NULL;
 bool FTCPSocketListeningTh::bThreadRun = false;
 
 FTCPSocketListeningTh::FTCPSocketListeningTh()
 {
     Thread = FRunnableThread::Create(this, TEXT("TCP_SocketListening"), 0, TPri_BelowNormal); 
 }
 
 FTCPSocketListeningTh::~FTCPSocketListeningTh()
 {
     delete Thread;
     Thread = NULL;
 }
 
 bool FTCPSocketListeningTh::Init()
 {
     bThreadRun = true;
     return true;
 }
 
 uint32 FTCPSocketListeningTh::Run()
 {
     while (bThreadRun)
     {
         FPlatformProcess::Sleep(1.f);
         GLog->Log("FTCPSocketListeningTh");
     }
     return 0;
 }
 
 void FTCPSocketListeningTh::Stop()
 {
 }
 
 FTCPSocketListeningTh* FTCPSocketListeningTh::RunSocketListening()
 {
     if (!Runnable && FPlatformProcess::SupportsMultithreading())
     {
         Runnable = new FTCPSocketListeningTh();
     }
     return Runnable;
 }
 
 void FTCPSocketListeningTh::Shutdown()
 {
     if (Runnable)
     {
         bThreadRun = false;
 
         delete Runnable;
         Runnable = NULL;
     }
 }

I call Run and Shutdown of threads in GameInstance:



 void USiennaGameInstance::Init()
 {
     GLog->Log("<<< USiennaGameInstance::USiennaGameInstance >>>");
 
         FServerStatusCheckingTh::RunServerChecking(); 
     FTCPSocketListeningTh::RunSocketListening();
 }
 
 void USiennaGameInstance::Shutdown()
 {
     FTCPSocketListeningTh::Shutdown();
     FServerStatusCheckingTh::Shutdown();
 }


Solved, I called a function to create a threads multiple times) eventually create a threads with the same name.

Morality of story: in any strange situation, go to sleep)