• 测试当前机器可以创建多少线程


    ulimit -a
    core file size          (blocks, -c) 0
    data seg size           (kbytes, -d) unlimited
    scheduling priority             (-e) 0
    file size               (blocks, -f) unlimited
    pending signals                 (-i) 3612
    max locked memory       (kbytes, -l) 64
    max memory size         (kbytes, -m) unlimited
    open files                      (-n) 1024
    pipe size            (512 bytes, -p) 8
    POSIX message queues     (bytes, -q) 819200
    real-time priority              (-r) 0
    stack size              (kbytes, -s) 8192
    cpu time               (seconds, -t) unlimited
    max user processes              (-u) 3612
    virtual memory          (kbytes, -v) unlimited
    file locks                      (-x) unlimited
    #include <stdio.h>
    #include <stdlib.h>
    #include <stdbool.h>
    #include <unistd.h>
    #include <string.h>
    #include <strings.h>
    #include <errno.h>
    
    #include <sys/stat.h>
    #include <sys/types.h>
    #include <sys/wait.h>
    #include <fcntl.h>
    #include <pthread.h>
    
    void* threadWork(void* arg)
    {
        while(1)
            sleep(1);
    }
    
    int main(int argc, char **argv)
    {
        pthread_t thID;
        int i = 0;
        while(1)
        {
            int err = pthread_create(&thID,NULL,threadWork,NULL);
            if (err != 0)
            {
                printf("%s
    ",strerror(err));
                exit(1);
            }
            printf("%d
    ",i++);
        }
        return 0;
    }
  • 相关阅读:
    014 停止进程
    014 创建进程的函数使用
    014 进程 获取当前目录 获取当前文件搜在目录 获取环境变量
    013 Windows进程及线程
    012 CopyFile
    011 异步I/O处理 003
    010 异步I/O处理 002
    MVVM
    ORM
    MVC
  • 原文地址:https://www.cnblogs.com/xiangtingshen/p/11967965.html
Copyright © 2020-2023  润新知