<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      c++ 線程 單例模式

       

       1 #include <iostream>
       2 #include <cstdio>
       3 #include <cstdlib>
       4 #include <cstring>
       5 #include <mutex>
       6 #include <thread>
       7 using namespace std;
       8 
       9 #define ll long long
      10 
      11 const int maxn=1e5+10;
      12 
      13 class Singleton {
      14 public:
      15     static Singleton* getInstance() {
      16         if (instance == nullptr) {
      17             lock_guard<mutex> lock(mtx);
      18             if (instance == nullptr)
      19                 instance = new Singleton();
      20         }
      21         return instance;
      22     }
      23 
      24     void dosomething() {
      25     }
      26 
      27     static void destoryInstance() {
      28         if (instance != nullptr) {
      29             delete instance;
      30             instance = nullptr;
      31         }
      32     }
      33 private:
      34     Sinleton(const Singleton&) = delete;
      35     Singleton& operator=(const Singleton&) = delete;
      36 
      37     static Singleton *instance;
      38     static mutex mtx;
      39 };
      40 
      41 void threadFunc(int id)
      42 {
      43     cout << "thread " + to_string(id) << endl;
      44     Singleton *s = Singleton::getInstance();
      45     s -> dosomething();
      46 }
      47 
      48 Singleton * Singleton::instance = nullptr;
      49 mutex Singleton::mtx;
      50 
      51 int main()
      52 {
      53     thread t1(threadFunc, 1);
      54     thread t2(threadFunc, 2);
      55     thread t3(threadFunc, 3);
      56     t1.join();
      57     t2.join();
      58     t3.join();
      59     Singleton::destoryInstance();
      60     return 0;
      61 }

       

      posted @ 2025-09-22 21:58  congmingyige  閱讀(12)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 国产av一区二区亚洲精品| 吉川爱美一区二区三区视频| av色蜜桃一区二区三区| 久久人人妻人人爽人人爽| 久久99精品久久久久久青青| 精品国际久久久久999波多野| 国产午夜福利在线机视频| 九九热精品在线视频观看| 久久精品一本到99热免费| 国产成人毛片在线视频| 成人网站免费观看永久视频下载| 亚洲天堂一区二区三区四区| 国产精品理论片| 国内不卡一区二区三区| 中文国产不卡一区二区| 国产一区二区精品自拍| 岛国中文字幕一区二区| 国产天美传媒性色av高清| 国产精品一码二码三码| 五月丁香六月综合缴情在线| 深夜免费av在线观看| 久久香蕉国产线看观看怡红院妓院| 乱人伦人妻中文字幕| 丰满巨乳淫巨大爆乳| 国产性一交一乱一伦一色一情 | 国内精品视频区在线2021 | 亚洲色大成网站www永久男同| 懂色AV| 免费费很色大片欧一二区| 国产精品久久久久鬼色| 亚洲首页一区任你躁xxxxx| 日韩人妻精品中文字幕专区| 亚洲精品一区国产| 施秉县| 国产精品尤物午夜福利| 精品一区二区三区女性色| 精品视频在线观看免费观看| 亚洲精品~无码抽插| 无码av岛国片在线播放| 在线看免费无码av天堂| 亚洲精品日韩久久精品|