1. 程式人生 > >C++11 thread::native_handle(6)

C++11 thread::native_handle(6)

原文地址:http://www.cplusplus.com/reference/thread/thread/native_handle/ public member function <thread>

std::thread::native_handle

native_handle_type native_handle();
Get native handle This member function is only present in class  if the library implementation supports it.

只有庫函式支援該函式時該方法才會有效。

If present, it returns a value used to access implementation-specific
 information associated to the thread.

如果有效,用於獲得與作業系統相關的原生執行緒控制代碼

例子:

#include <iostream>
#include <thread>
#include <ctime>
using namespace std;
void show(int n){
	cout<<"n="<<n<<endl;
}
int main()
{
	thread t(show,18);
	cout<<"t.get_id="<<t.get_id()<<endl;
	auto tn=t.native_handle();
	t.join();
	cout<<"tn="<<tn<<endl;		
}

執行截圖:



Parameters

none

Return value

Data races

Unspecified.

Exception safety

Unspecified.


—————————————————————————————————————————————————————————————————

//寫的錯誤或者不好的地方請多多指導,可以在下面留言或者點選左上方郵件地址給我發郵件,指出我的錯誤以及不足,以便我修改,更好的分享給大家,謝謝。

轉載請註明出處:http://blog.csdn.net/qq844352155

author:天下無雙

Email:[email protected]

2014-9-4

於GDUT

——————————————————————————————————————————————————————————————————


相關推薦

C++11 thread::native_handle(6)

原文地址:http://www.cplusplus.com/reference/thread/thread/native_handle/ public member function <thread> std::thread::native_handle

C++11 thread程式設計呼叫類方法並傳入引數

#include <thread> #include <iostream> class classA { public : classA() { std::cout<<" classA " <<std::endl; }

C++11,thread,sleep,鎖

相關連結:https://blog.csdn.net/knowledgebao/article/details/85076661 sleep: #include <thread> #include <iostream> auto start = std::chro

基於C++11 thread 實現執行緒池

轉自:https://blog.csdn.net/u013507368/article/details/48130151 這裡基於C++11 thread實現執行緒池,執行緒池不可拷貝。   1 nocopyable類     不可拷貝基類繼承

漫談c++11 Thread庫之使寫多執行緒程式

      c++11中最重要的特性之一就是對多執行緒的支援了,然而《c++ primer》5th卻沒有這部分內容的介紹,著實人有點遺憾。在網上了解到了一些關於thread庫的內容。這是幾個比較不錯的學習thread庫的資源: 前兩個網站我還是非常喜歡的,都是線上的幫助手冊,兩個選擇其中一個就可以了,看

漫談C++11 Thread庫之原子操作

      我在之前一篇博文《漫談C++11 Thread庫之使寫多執行緒程式》中,著重介紹了<thread>標頭檔案中的std::thread類以及其上的一些基本操作,至此我們動手寫多執行緒程式已經基本沒有問題了。但是,單執行緒的那些"坑"我們仍還不知道怎麼去避免。 多執行緒存在的問題  

C++之多執行緒(C++11 thread.h檔案實現多執行緒)

轉載自: 與 C++11 多執行緒相關的標頭檔案 C++11 新標準中引入了四個標頭檔案來支援多執行緒程式設計,他們分別是<atomic> ,<thread>,<mutex>,<condition_variable>和&l

c++11 thread類簡單使用

近日專案需要用到多執行緒,由於之前沒有寫過c++程式碼,經過研究,發現c++11引入了一個多執行緒類,就寫了一個簡單的例子,做個簡單記錄。 –2018年的今天很冷,全球股市暴跌。 簡單多執行緒例

c++11 thread 封裝成簡單執行緒類

       這幾天學習qt的時候發現Qt的執行緒類和java的執行緒類差不多,因為要讀取攝像頭然後顯示到介面上,執行緒需要不停的讀。大體結構就是這樣了: void run(){ while( !當前執行緒被中斷){ //work } }

C++ 11 thread 執行緒管理

std::thread 在 <thread> 標頭檔案中宣告,因此使用 std::thread 時需要包含 <thread> 標頭檔案。std::thread 構造default (1)thread() noexcept; initialization

C++11 thread 及互斥鎖、條件變數

啟動的格式: #include <thread>//包含標頭檔案 void fucntion();//定義一個執行緒執行的函式 thread t1(fucntion);//執行緒啟

Cocos2dx 3.0 過渡篇(二十七)C++11多線程std::thread的簡單使用(下)

fonts fun avi 2dx read 來源 cpp break 輸出 本篇接上篇繼續講:上篇傳送門:http://blog.csdn.net/star530/article/details/24186783簡單的東西我都說的幾乎相同了,想挖點深的差點把自己給填進

C++入門經典-例6.11-使用指針變量遍歷二維數組

none oid iostream 內存 sin hid pre 控制臺應用程序 closed 1:代碼如下: // 6.11.cpp : 定義控制臺應用程序的入口點。 // #include "stdafx.h" #include <iostream> #

c++11多執行緒 thread

 1.thread建構函式 default (1) thread() noexcept; initialization (2) template <class Fn, class... Args> explicit

C++116種記憶體序總結__std::memory_order_acquire_等

對於C++11的6種併發查了不少相關資料,這裡作一個總結和理解std::memory_order_relaxed,std::memory_order_consume,std::memory_order_acquire std::memory_order_release,std::memory_ord

thread safe singleton in c++11

class CSingleton final { public :      static CSingleton& GetInstance(); private

C++11 併發指南二(std::thread 詳解)

上一篇部落格《C++11 併發指南一(C++11 多執行緒初探)》中只是提到了 std::thread 的基本用法,並給出了一個最簡單的例子,本文將稍微詳細地介紹 std::thread 的用法。 std::thread 在 <thread> 標頭檔案中宣告,因此使用 std::thread 時

C++11多執行緒thread引數傳遞問題

目錄 寫在前面 thread類的建構函式 join函式 detach函式 thread中引數傳遞 類物件作為引數 類中函式作為引數 參考書籍 寫在前面 多執行緒在很多地方都是必須要掌握的方法,這裡先說一下,thread物件的引數傳遞問題 thread類

c++11特性裡的多執行緒thread的用法

建立和啟動一條C++執行緒就像在C++原始碼中新增執行緒標頭檔案那麼簡便。我們來看看如何建立一個簡單的帶執行緒的HelloWorld: #include <iostream> #include <thread> using namespace std

C++11 多執行緒學習----std::thread類的簡單使用

一 C++11多執行緒簡介    C++11標準庫會提供類thread(std::thread)。若要執行一個執行緒,可以建立一個類thread的實體,其初始引數為一個函式物件,以及該函式物件所需要的