I wonder about thread id. Plz answer me.

Hi, everyone. First of all, I'm so sorry that I can't speak English Well.

I wonder about thread id. Please look at codes below.

using UnityEngine; 
using System.Collections; 
using System.Threading; 

public class TestScript : MonoBehaviour { 

    void Start () { 
          Debug.Log("current thread id: " + Thread.CurrentThread.GetHashCode().ToString()); 
          (new Thread(thread_test)).Start(); 

    static void thread_test() 
          Debug.Log("created thread id: " + Thread.CurrentThread.GetHashCode().ToString()); 

And I got the result below with console panel.

current thread id: 1 
created thread id: 1 

I expected the result below.

current thread id: 1 
created thread id: 2 

Why is 'created thread id' 1? Why isn't it 2? Are 'current thread' and 'created thread' the same thread?

Please tell me about that.

Yeah, I found the same issue. My work around it was to store the current thread object itself (instead of the id), and to compare the references, as below.

object.ReferenceEquals(System.Threading.Thread.CurrentThread, mainThreadObject)

I also check mainThreadObject.IsAlive, but it always is. Hope it helps.

You probably want Thread.CurrentThread.ManagedThreadId instead

GetHashCode isn't guaranteed to be unique