How can i get current thread id in function that runs in thread?
<p><strong>How can i get current thread ID in a function that runs on the thread?</strong>
I tried like this but it doesn't work.</p>

<pre><code>#include &lt;thread&gt;
#include &lt;iostream&gt;

using namespace std;

#define NUM_TH 4

void printhello(thread t) { 
    auto th_id = t.get_id();
    cout &lt;&lt; "Hello world! Thread ID, "&lt;&lt;th_id&lt;&lt; endl;
}

void main() {   
    thread th[NUM_TH];

    for (int i = 0; i &lt; NUM_TH; i++) {
        th[i]=thread(printhello,th[i]); 
        th[i].join();
    }

}
</code></pre>

<p>i'm getting error "cannot convert argument 1 from void to t"</p>