1樓:
雙休在家自己搞了一下...不知道算不算正確的解決方案...
ChildThread
#include
#include
"DataBag.h"
class
ChildThread
;#include
"ChildThread.h"
#include
#include
ChildThread
::ChildThread
(DataBag
*bag
)ChildThread
::~ChildThread
()void
ChildThread
::doSomeThing
()fbag
->addInt
(vec
);std
::cout
<<"ChildThread::doSomeThing : Time = "
< ++<< std:: endl ;fbag ->cleanInt ();std ::cout <<"ChildThread::doSomeThing : Clean" < endl;} std:: cout <<"ChildThread::doSomeThing : End" < endl;} void ChildThread ::setFdo (boolb) RootThread #include "ChildThread.h" #include "DataBag.h" #include class RootThread private :DataBag fbag ;ChildThread fchild;}; #include "RootThread.h" #include #include #include RootThread ::RootThread(): fchild(& fbag )RootThread ::~RootThread ()void RootThread ::show ()void RootThread ::begin ()DataBag class DataBag ;#include "DataBag.h" #include #include std::mutex mtx; // locks access to counterDataBag ::DataBag ()DataBag ::~DataBag ()void DataBag ::addInt (const std:: vector vecint )void DataBag ::cleanInt ()void DataBag ::showInt ()main int_tmain (int argc ,_TCHAR *argv)rt .end ();std ::cout <<"_tmain::end" < endl ;charch; std:: cin>>ch; return0;} 小島上的做題家 當你建立乙個thread的時候,引數傳遞是分兩步的,先傳給std thread,再傳給函式。std thread的constructor把你的引數copy到新的thread的memory space裡。這時所有的引數都被複製了,以rvalue的形式存在於新的thread的memory... 有些壓力能釋放,有些釋放不了。既想回老家老婆孩子熱炕頭,又想在大城市拿高收入,拿著高收入又想著這是青春飯,迷茫以後怎麼辦。30幾歲開始考慮養老,可想想還有二三十年才能退休就又茫然了,對未來的不確定性極度恐懼。現在能早餐麥當勞,以後只能在家下麵條。回到老家沒錢沒人脈,除了在外打工的那幾年好點外,以後混... 筱玲 非常理解這種感受,但既然已經是全職媽媽了,那麼首先做的就是擺正心態,找到自己的價值 全職媽媽的價值可是很大的 然後對於不好的情緒,多跟老公溝通 是溝通,不是吵架哦 找到身邊的媽媽群聊聊,或者找到自己的興趣愛好放鬆下,又或者暫時不換家務什麼的,看個小電影放鬆下 其實全職媽媽是非常不容易的,最難平...C 的std thread是怎麼進行引數傳遞的?
程式設計師該如何釋放壓力
全職媽媽應該如何釋放糟糕的情緒?