zoukankan      html  css  js  c++  java
  • Linux 新建线程 简单使用

    PS:在 Android 下运行正常。

    #include "MainWindow.h"
    #include "ui_MainWindow.h"
    
    #include <QDebug>
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    int main_z();
    
    void MainWindow::on_pushButton_clicked()
    {
        main_z();
    }
    
    
    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    
    #include<stdio.h>
    #include<stdlib.h>
    #include<pthread.h>
    #include<errno.h>
    #include<unistd.h>
    
    void* thread1(void*);
    
    int main_z()
    {
        qDebug() << "main_z in";
        pthread_t tid1;
        int rc1=0;
    
        rc1 = pthread_create(&tid1, NULL, thread1, &tid1);
        if(rc1 != 0)
        {
            QString str1 = __func__;
            QString str2 = strerror(rc1);
            qDebug() << str1 + str2;
        }
        qDebug() << "main_z out";
        //exit(0);
    }
    
    void* thread1(void* arg)
    {
        qDebug() << "thread1 in";
        ushort us = (unsigned int)pthread_self();
        qDebug() << "this is thread1, thread id is " +QString::number(us);
        qDebug() << "thread1 out";
        pthread_exit(0);
    }
    

      

  • 相关阅读:
    多对多关系表的创建方式、forms组件
    SweetAler弹框插件与分页器插件
    Django数据库查询优化与AJAX
    django orm(2)
    Django orm(1)
    Django之视图层与模板层
    Django之路由层
    初识Django之前端后端与数据库的配置
    面试题49
    web框架之初识Django
  • 原文地址:https://www.cnblogs.com/codeskilla/p/4933619.html
Copyright © 2011-2022 走看看