网络编程6:线程池简介

2023-05-16

1. 线程池相关结构体

 

struct threadpool_t {

    pthread_mutex_t lock;               /* 用于锁住本结构体 */    
    pthread_mutex_t thread_counter;     /* 记录忙状态线程个数de琐 -- busy_thr_num */

    pthread_cond_t queue_not_full;      /* 当任务队列满时,添加任务的线程阻塞,等待此条件变量 */
    pthread_cond_t queue_not_empty;     /* 任务队列里不为空时,通知等待任务的线程 */

    pthread_t *threads;                 /* 存放线程池中每个线程的tid。数组 */
    pthread_t adjust_tid;               /* 存管理线程tid */
    threadpool_task_t *task_queue;      /* 任务队列(数组首地址) */

    int min_thr_num;                    /* 线程池最小线程数 */
    int max_thr_num;                    /* 线程池最大线程数 */
    int live_thr_num;                   /* 当前存活线程个数 */
    int busy_thr_num;                   /* 忙状态线程个数 */
    int wait_exit_thr_num;              /* 要销毁的线程个数 */

    int queue_front;                    /* task_queue队头下标 */
    int queue_rear;                     /* task_queue队尾下标 */
    int queue_size;                     /* task_queue队中实际任务数 */
    int queue_max_size;                 /* task_queue队列可容纳任务数上限 */

    int shutdown;                       /* 标志位,线程池使用状态,true或false */
};


typedef struct {

    void *(*function)(void *);          /* 函数指针,回调函数 */
    void *arg;                          /* 上面函数的参数 */

} threadpool_task_t;                    /* 各子线程任务结构体 */

 

2. 线程池关键函数

线程池模块分析:

    1. main();        

        创建线程池。

        向线程池中添加任务。 借助回调处理任务。

        销毁线程池。

    2. pthreadpool_create();

        创建线程池结构体 指针。

        初始化线程池结构体 {  N 个成员变量 }

        创建 N 个任务线程。

        创建 1 个管理者线程。

        失败时,销毁开辟的所有空间。(释放)

    3. threadpool_thread()

        进入子线程回调函数。

        接收参数 void *arg  --》 pool 结构体

        加锁 --》lock --》 整个结构体锁

        判断条件变量 --》 wait  -------------------170

    4. adjust_thread()

        循环 10 s 执行一次。

        进入管理者线程回调函数

        接收参数 void *arg  --》 pool 结构体

        加锁 --》lock --》 整个结构体锁

        获取管理线程池要用的到 变量。    task_num, live_num, busy_num

        根据既定算法,使用上述3变量,判断是否应该 创建、销毁线程池中 指定步长的线程。

    5. threadpool_add ()

        总功能:

            模拟产生任务。   num[20]

            设置回调函数, 处理任务。  sleep(1) 代表处理完成。

        内部实现:
    
            加锁

            初始化 任务队列结构体成员。   回调函数 function, arg

            利用环形队列机制,实现添加任务。 借助队尾指针挪移 % 实现。

            唤醒阻塞在 条件变量上的线程。
    
            解锁

    6.  从 3. 中的wait之后继续执行,处理任务。

        加锁
        
        获取 任务处理回调函数,及参数

        利用环形队列机制,实现处理任务。 借助队头指针挪移 % 实现。

        唤醒阻塞在 条件变量 上的 server。

        解锁

        加锁 

        改忙线程数++

        解锁

        执行处理任务的线程

        加锁 

        改忙线程数——

        解锁

    7. 创建 销毁线程

        管理者线程根据 task_num, live_num, busy_num  

        根据既定算法,使用上述3变量,判断是否应该 创建、销毁线程池中 指定步长的线程。

        如果满足 创建条件

            pthread_create();   回调 任务线程函数。        live_num++

        如果满足 销毁条件

            wait_exit_thr_num = 10;  

            signal 给 阻塞在条件变量上的线程 发送 假条件满足信号    

            跳转至  --170 wait阻塞线程会被 假信号 唤醒。判断: wait_exit_thr_num  > 0 pthread_exit();    

 

3. 线程池使用举例

#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <errno.h>
#include "threadpool.h"

#define DEFAULT_TIME 10                 /*10s检测一次*/
#define MIN_WAIT_TASK_NUM 10            /*如果queue_size > MIN_WAIT_TASK_NUM 添加新的线程到线程池*/ 
#define DEFAULT_THREAD_VARY 10          /*每次创建和销毁线程的个数*/
#define true 1
#define false 0

typedef struct {
    void *(*function)(void *);          /* 函数指针,回调函数 */
    void *arg;                          /* 上面函数的参数 */
} threadpool_task_t;                    /* 各子线程任务结构体 */

/* 描述线程池相关信息 */

struct threadpool_t {
    pthread_mutex_t lock;               /* 用于锁住本结构体 */    
    pthread_mutex_t thread_counter;     /* 记录忙状态线程个数de琐 -- busy_thr_num */

    pthread_cond_t queue_not_full;      /* 当任务队列满时,添加任务的线程阻塞,等待此条件变量 */
    pthread_cond_t queue_not_empty;     /* 任务队列里不为空时,通知等待任务的线程 */

    pthread_t *threads;                 /* 存放线程池中每个线程的tid。数组 */
    pthread_t adjust_tid;               /* 存管理线程tid */
    threadpool_task_t *task_queue;      /* 任务队列(数组首地址) */

    int min_thr_num;                    /* 线程池最小线程数 */
    int max_thr_num;                    /* 线程池最大线程数 */
    int live_thr_num;                   /* 当前存活线程个数 */
    int busy_thr_num;                   /* 忙状态线程个数 */
    int wait_exit_thr_num;              /* 要销毁的线程个数 */

    int queue_front;                    /* task_queue队头下标 */
    int queue_rear;                     /* task_queue队尾下标 */
    int queue_size;                     /* task_queue队中实际任务数 */
    int queue_max_size;                 /* task_queue队列可容纳任务数上限 */

    int shutdown;                       /* 标志位,线程池使用状态,true或false */
};

void *threadpool_thread(void *threadpool);

void *adjust_thread(void *threadpool);

int is_thread_alive(pthread_t tid);
int threadpool_free(threadpool_t *pool);

//threadpool_create(3,100,100);  
threadpool_t *threadpool_create(int min_thr_num, int max_thr_num, int queue_max_size)
{
    int i;
    threadpool_t *pool = NULL;          /* 线程池 结构体 */

    do {
        if((pool = (threadpool_t *)malloc(sizeof(threadpool_t))) == NULL) {  
            printf("malloc threadpool fail");
            break;                                      /*跳出do while*/
        }

        pool->min_thr_num = min_thr_num;
        pool->max_thr_num = max_thr_num;
        pool->busy_thr_num = 0;
        pool->live_thr_num = min_thr_num;               /* 活着的线程数 初值=最小线程数 */
        pool->wait_exit_thr_num = 0;
        pool->queue_size = 0;                           /* 有0个产品 */
        pool->queue_max_size = queue_max_size;          /* 最大任务队列数 */
        pool->queue_front = 0;
        pool->queue_rear = 0;
        pool->shutdown = false;                         /* 不关闭线程池 */

        /* 根据最大线程上限数, 给工作线程数组开辟空间, 并清零 */
        pool->threads = (pthread_t *)malloc(sizeof(pthread_t)*max_thr_num); 
        if (pool->threads == NULL) {
            printf("malloc threads fail");
            break;
        }
        memset(pool->threads, 0, sizeof(pthread_t)*max_thr_num);

        /* 给 任务队列 开辟空间 */
        pool->task_queue = (threadpool_task_t *)malloc(sizeof(threadpool_task_t)*queue_max_size);
        if (pool->task_queue == NULL) {
            printf("malloc task_queue fail");
            break;
        }

        /* 初始化互斥琐、条件变量 */
        if (pthread_mutex_init(&(pool->lock), NULL) != 0
                || pthread_mutex_init(&(pool->thread_counter), NULL) != 0
                || pthread_cond_init(&(pool->queue_not_empty), NULL) != 0
                || pthread_cond_init(&(pool->queue_not_full), NULL) != 0)
        {
            printf("init the lock or cond fail");
            break;
        }

        /* 启动 min_thr_num 个 work thread */
        for (i = 0; i < min_thr_num; i++) {
            pthread_create(&(pool->threads[i]), NULL, threadpool_thread, (void *)pool);   /*pool指向当前线程池*/
            printf("start thread 0x%x...\n", (unsigned int)pool->threads[i]);
        }
        pthread_create(&(pool->adjust_tid), NULL, adjust_thread, (void *)pool);     /* 创建管理者线程 */

        return pool;

    } while (0);

    threadpool_free(pool);      /* 前面代码调用失败时,释放poll存储空间 */

    return NULL;
}

/* 向线程池中 添加一个任务 */
//threadpool_add(thp, process, (void*)&num[i]);   /* 向线程池中添加任务 process: 小写---->大写*/

int threadpool_add(threadpool_t *pool, void*(*function)(void *arg), void *arg)
{
    pthread_mutex_lock(&(pool->lock));

    /* ==为真,队列已经满, 调wait阻塞 */
    while ((pool->queue_size == pool->queue_max_size) && (!pool->shutdown)) {
        pthread_cond_wait(&(pool->queue_not_full), &(pool->lock));
    }

    if (pool->shutdown) {
        pthread_cond_broadcast(&(pool->queue_not_empty));
        pthread_mutex_unlock(&(pool->lock));
        return 0;
    }

    /* 清空 工作线程 调用的回调函数 的参数arg */
    if (pool->task_queue[pool->queue_rear].arg != NULL) {
        pool->task_queue[pool->queue_rear].arg = NULL;
    }

    /*添加任务到任务队列里*/
    pool->task_queue[pool->queue_rear].function = function;
    pool->task_queue[pool->queue_rear].arg = arg;
    pool->queue_rear = (pool->queue_rear + 1) % pool->queue_max_size;       /* 队尾指针移动, 模拟环形 */
    pool->queue_size++;

    /*添加完任务后,队列不为空,唤醒线程池中 等待处理任务的线程*/
    pthread_cond_signal(&(pool->queue_not_empty));
    pthread_mutex_unlock(&(pool->lock));

    return 0;
}

/* 线程池中各个工作线程 */
void *threadpool_thread(void *threadpool)
{
    threadpool_t *pool = (threadpool_t *)threadpool;
    threadpool_task_t task;

    while (true) {
        /* Lock must be taken to wait on conditional variable */
        /*刚创建出线程,等待任务队列里有任务,否则阻塞等待任务队列里有任务后再唤醒接收任务*/
        pthread_mutex_lock(&(pool->lock));

        /*queue_size == 0 说明没有任务,调 wait 阻塞在条件变量上, 若有任务,跳过该while*/
        while ((pool->queue_size == 0) && (!pool->shutdown)) {  
            printf("thread 0x%x is waiting\n", (unsigned int)pthread_self());
            pthread_cond_wait(&(pool->queue_not_empty), &(pool->lock));

            /*清除指定数目的空闲线程,如果要结束的线程个数大于0,结束线程*/
            if (pool->wait_exit_thr_num > 0) {
                pool->wait_exit_thr_num--;

                /*如果线程池里线程个数大于最小值时可以结束当前线程*/
                if (pool->live_thr_num > pool->min_thr_num) {
                    printf("thread 0x%x is exiting\n", (unsigned int)pthread_self());
                    pool->live_thr_num--;
                    pthread_mutex_unlock(&(pool->lock));

                    pthread_exit(NULL);
                }
            }
        }

        /*如果指定了true,要关闭线程池里的每个线程,自行退出处理---销毁线程池*/
        if (pool->shutdown) {
            pthread_mutex_unlock(&(pool->lock));
            printf("thread 0x%x is exiting\n", (unsigned int)pthread_self());
            pthread_detach(pthread_self());
            pthread_exit(NULL);     /* 线程自行结束 */
        }

        /*从任务队列里获取任务, 是一个出队操作*/
        task.function = pool->task_queue[pool->queue_front].function;
        task.arg = pool->task_queue[pool->queue_front].arg;

        pool->queue_front = (pool->queue_front + 1) % pool->queue_max_size;       /* 出队,模拟环形队列 */
        pool->queue_size--;

        /*通知可以有新的任务添加进来*/
        pthread_cond_broadcast(&(pool->queue_not_full));

        /*任务取出后,立即将 线程池琐 释放*/
        pthread_mutex_unlock(&(pool->lock));

        /*执行任务*/ 
        printf("thread 0x%x start working\n", (unsigned int)pthread_self());
        pthread_mutex_lock(&(pool->thread_counter));                            /*忙状态线程数变量琐*/
        pool->busy_thr_num++;                                                   /*忙状态线程数+1*/
        pthread_mutex_unlock(&(pool->thread_counter));

        (*(task.function))(task.arg);                                           /*执行回调函数任务*/
        //task.function(task.arg);                                              /*执行回调函数任务*/

        /*任务结束处理*/ 
        printf("thread 0x%x end working\n", (unsigned int)pthread_self());
        pthread_mutex_lock(&(pool->thread_counter));
        pool->busy_thr_num--;                                       /*处理掉一个任务,忙状态数线程数-1*/
        pthread_mutex_unlock(&(pool->thread_counter));
    }

    pthread_exit(NULL);
}

/* 管理线程 */
void *adjust_thread(void *threadpool)
{
    int i;
    threadpool_t *pool = (threadpool_t *)threadpool;
    while (!pool->shutdown) {

        sleep(DEFAULT_TIME);                                    /*定时 对线程池管理*/

        pthread_mutex_lock(&(pool->lock));
        int queue_size = pool->queue_size;                      /* 关注 任务数 */
        int live_thr_num = pool->live_thr_num;                  /* 存活 线程数 */
        pthread_mutex_unlock(&(pool->lock));

        pthread_mutex_lock(&(pool->thread_counter));
        int busy_thr_num = pool->busy_thr_num;                  /* 忙着的线程数 */
        pthread_mutex_unlock(&(pool->thread_counter));

        /* 创建新线程 算法: 任务数大于最小线程池个数, 且存活的线程数少于最大线程个数时 如:30>=10 && 40<100*/
        if (queue_size >= MIN_WAIT_TASK_NUM && live_thr_num < pool->max_thr_num) {
            pthread_mutex_lock(&(pool->lock));  
            int add = 0;

            /*一次增加 DEFAULT_THREAD 个线程*/
            for (i = 0; i < pool->max_thr_num && add < DEFAULT_THREAD_VARY
                    && pool->live_thr_num < pool->max_thr_num; i++) {
                if (pool->threads[i] == 0 || !is_thread_alive(pool->threads[i])) {
                    pthread_create(&(pool->threads[i]), NULL, threadpool_thread, (void *)pool);
                    add++;
                    pool->live_thr_num++;
                }
            }

            pthread_mutex_unlock(&(pool->lock));
        }

        /* 销毁多余的空闲线程 算法:忙线程X2 小于 存活的线程数 且 存活的线程数 大于 最小线程数时*/
        if ((busy_thr_num * 2) < live_thr_num  &&  live_thr_num > pool->min_thr_num) {

            /* 一次销毁DEFAULT_THREAD个线程, 隨機10個即可 */
            pthread_mutex_lock(&(pool->lock));
            pool->wait_exit_thr_num = DEFAULT_THREAD_VARY;      /* 要销毁的线程数 设置为10 */
            pthread_mutex_unlock(&(pool->lock));

            for (i = 0; i < DEFAULT_THREAD_VARY; i++) {
                /* 通知处在空闲状态的线程, 他们会自行终止*/
                pthread_cond_signal(&(pool->queue_not_empty));
            }
        }
    }

    return NULL;
}

int threadpool_destroy(threadpool_t *pool)
{
    int i;
    if (pool == NULL) {
        return -1;
    }
    pool->shutdown = true;

    /*先销毁管理线程*/
    pthread_join(pool->adjust_tid, NULL);

    for (i = 0; i < pool->live_thr_num; i++) {
        /*通知所有的空闲线程*/
        pthread_cond_broadcast(&(pool->queue_not_empty));
    }
    for (i = 0; i < pool->live_thr_num; i++) {
        pthread_join(pool->threads[i], NULL);
    }
    threadpool_free(pool);

    return 0;
}

int threadpool_free(threadpool_t *pool)
{
    if (pool == NULL) {
        return -1;
    }

    if (pool->task_queue) {
        free(pool->task_queue);
    }
    if (pool->threads) {
        free(pool->threads);
        pthread_mutex_lock(&(pool->lock));
        pthread_mutex_destroy(&(pool->lock));
        pthread_mutex_lock(&(pool->thread_counter));
        pthread_mutex_destroy(&(pool->thread_counter));
        pthread_cond_destroy(&(pool->queue_not_empty));
        pthread_cond_destroy(&(pool->queue_not_full));
    }
    free(pool);
    pool = NULL;

    return 0;
}

int threadpool_all_threadnum(threadpool_t *pool)
{
    int all_threadnum = -1;                 // 总线程数

    pthread_mutex_lock(&(pool->lock));
    all_threadnum = pool->live_thr_num;     // 存活线程数
    pthread_mutex_unlock(&(pool->lock));

    return all_threadnum;
}

int threadpool_busy_threadnum(threadpool_t *pool)
{
    int busy_threadnum = -1;                // 忙线程数

    pthread_mutex_lock(&(pool->thread_counter));
    busy_threadnum = pool->busy_thr_num;    
    pthread_mutex_unlock(&(pool->thread_counter));

    return busy_threadnum;
}

int is_thread_alive(pthread_t tid)
{
    int kill_rc = pthread_kill(tid, 0);     //发0号信号,测试线程是否存活
    if (kill_rc == ESRCH) {
        return false;
    }
    return true;
}

/*测试*/ 

#if 1

/* 线程池中的线程,模拟处理业务 */
void *process(void *arg)
{
    printf("thread 0x%x working on task %d\n ",(unsigned int)pthread_self(),(int)arg);
    sleep(1);                           //模拟 小---大写
    printf("task %d is end\n",(int)arg);

    return NULL;
}

int main(void)
{
    /*threadpool_t *threadpool_create(int min_thr_num, int max_thr_num, int queue_max_size);*/

    threadpool_t *thp = threadpool_create(3,100,100);   /*创建线程池,池里最小3个线程,最大100,队列最大100*/
    printf("pool inited");

    //int *num = (int *)malloc(sizeof(int)*20);
    int num[20], i;
    for (i = 0; i < 20; i++) {
        num[i] = i;
        printf("add task %d\n",i);
        
        /*int threadpool_add(threadpool_t *pool, void*(*function)(void *arg), void *arg) */

        threadpool_add(thp, process, (void*)&num[i]);   /* 向线程池中添加任务 */
    }

    sleep(10);                                          /* 等子线程完成任务 */
    threadpool_destroy(thp);

    return 0;
}

#endif

4. 参考

linux c 线程池简介

 

 

 

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

网络编程6:线程池简介 的相关文章

  • Go Error 错误处理总结

    Go Error 一 设计理念 简单考虑成功而不是只有成功没有隐藏的控制流完全交给调用者控制 errorError are values xff08 Rob Pike xff09 二 错误与异常 go 中的错误处理主要使用到error 和
  • Linux创建新用户和key登陆

    1 root用户身份登陆 2 新增一个用户 useradd m new user name 3 切换至新用户 su new user name 4 生成公钥和私钥 ssh keygen t rsa 一路回车 5 cd ssh 6 cat i
  • 详解C++中的ANSI与Unicode和UTF8三种字符编码基本原理与相互转换

    目录 1 概述 2 Visual Studio中的字符编码 3 ANSI窄字节编码 4 Unicode宽字节编码 5 UTF8编码 6 如何使用字符编码 7 三种字符编码之间的相互转换 xff08 附源码 xff09 7 1 ANSI编码与
  • 让ubuntu16.04开机进入命令行模式

    让ubuntu16 04开机进入命令行模式 使用Ubuntu时 xff0c 有时候我们不想开机进入桌面 xff0c 想直接进入命令行 xff0c 这样启动的比较快 xff0c 1 首先我们修改grub文件 xff0c 改为如图所示 xff1
  • centos7 开启关闭服务

    centos 7 中使用systemctl工具来管理服务程序 xff0c 包括了service和chkconfig 启动一个服务 xff1a systemctl start firewalld service 关闭一个服务 xff1a sy
  • 基于SPWM的逆变器程序应用及自制电路

    自制逆变器的电路及程序应用 设计并制作 一个简易逆变器 xff0c 其结构如图所示 逆变器进行负载试验时 xff0c 需在其输出端接负载 通常情况下 xff0c 输出电能消耗在该负载上 2 基本要求 逆变器输出端仅连接电阻性负载 xff0c
  • DNS:Bind安全配置、视图

    Bind中的安全配置 Bind支持ACL xff08 访问控制列表 xff09 功能 xff1a 主要实现把一个或多个地址归并为一个集合 xff0c 并通过一个统一的名称调用 格式 xff1a acl acl name ip ip net
  • Mozilla 修复跨平台加密库 NSS 中的严重漏洞

    聚焦源代码安全 xff0c 网罗国内外最新资讯 xff01 编译 xff1a 代码卫士 Mozilla 修复了影响跨平台网络安全服务 NSS 加密库中一个严重的内存损坏漏洞 CVE 2021 43527 NSS 可用于开发启用安全功能的客户
  • Ubuntu下将anaconda打包移植到另一个台Ubuntu下,使用ananconda的离线包库,安装包

    由于某种需求 xff0c 需要将annaconda移植到另外一台Ubuntu下 xff0c 而且另一台无法联网 xff0c 而且需要安装一些包 xff0c 使用wheel和setup安装失败后使用的这种方法 思路 xff1a 将本地的ann
  • IT66121 720P@60配置文件

    这里为IT66121 720P 64 60的配置文件 xff0c 在Linux下我是使用i2cset工具先验证再写驱动的 xff0c 所以这里我也简单记录一下 IT66121分为两个bank xff0c 一个是bank0的配置 xff0c
  • CCS编译报错 error #10234-D: unresolved symbols remain

    最近刚刚接触CCS编译器 xff0c 然后自己搭建的工程中出现了这个报错 xff1a 检查了头文件以及库都是正常的 xff0c 但就不清楚是什么原因 xff0c 最后同事帮忙解决了这个问题 xff0c 如下解决 xff1a 工程右键选择Pr
  • AM4379 关于CCS下无法正常加载程序

    最近调试4379的时候发现了个问题 xff0c 这里记录下 将boot set设置为全1模式下 xff0c 然后加载程序 xff0c 发现加载是可以正常加载 xff0c 但是运行图标是灰色的 xff08 如图 xff09 xff0c 然后我
  • S5P6818 卸载驱动时报错

    调试6818的时候 xff0c 在卸载驱动时候报了这样的错误 xff1a rmmod can 39 t change directory to 39 3 4 39 39 No such file or directory 解决办法 xff1
  • S5P6818 移植phytool报错

    下载地址 xff1a GitHub wkz phytool Linux MDIO register access 编译 xff1a make CC 61 home tronlong 6818 arm 2009q3 bin arm none
  • Ubuntu16.04 卸载vmware

    1 先查看安装的虚拟机 vmware installer l 然后会显示版本和产品名称 Product Name Product Version 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61
  • HPS是什么?包括哪些内容?

    文章来自 xff1a http bbs eeworld com cn thread 454766 1 1 html 1 HPS Hard processor system 字面意思就是硬件处理器系统 xff0c 应该指的是和arm核相连的硬
  • Ubuntu16.04 段错误(核心已转储)的解决办法

    由于软件需求我写了个测试软件 xff0c 我定义两个u8 的buf为1280 720 8的大小 xff0c 也差不多要接近于15M 的大小了 xff0c 在语法没有错误的情况下直接报段错误 xff08 核心已转储 xff09 的错误 查找了
  • WebDriver使用指南(完整篇)

    第1章 入门 1 1 下载selenium2 0的lib包 http code google com p selenium downloads list 官方UserGuide xff1a http seleniumhq org docs
  • 关于Virtualbox使用win7鼠标卡顿问题

    工作中要用到虚拟机 xff0c 自己装了一个win7系统 xff0c 结果发现鼠标卡顿的不行 xff0c 不能流畅运行 xff0c 于是查找了很多文章 xff0c 终于解决了问题 软件版本 xff1a virtualbox7 0 解决方案
  • Ubuntu挂载分区

    1 查看本地分区 xff0c 找到你想要挂载的分区名称 sudo fdisk l 图中为以整块2T硬盘 xff0c 分为5 6 7 8 9区 xff0c 以 dev sdb7 为例 xff0c 想要将其挂载到 home plan other

随机推荐

  • 允许远程该计算机的其他用户

    当你想进入服务器的其他用户时 xff0c 发现通过administrator是无法直接切换用户的 xff0c 那么我们应该怎么设置呢 xff1f 解决方案 xff1a 1 右击计算机 gt 属性 gt 高级系统设置 gt 远程 xff0c
  • 学习Linux 编程的几本好书

    这次涉及到了具体的平台 GNU Linux Linux下开发与明显不同于Windows平台的特点 xff0c 从开发工具到项目组织 xff0c 都有较大的差距 首先声明 xff0c 在做Linux平台开发之前 xff0c 首先要熟练使用Li
  • IE8报错:Unable to modify the parent container element before the child element is closed

    xfeff xfeff 转自 xff1a http blog csdn net xinwang article details 9786447 IE8中会报 HTML Parsing Error Unable to modify the p
  • APNs 访问不到的问题

    APNs会将链接太频繁的链接视为DDos攻击 xff0c 所以链接频率不要太高 目前每5分钟连接接一次 因为使用了加密链接 xff0c 会被GFW随机阻断 看脸 看有的说建议用国外VPS 单个ip连接每次发送消息数量不要超过1000条 xf
  • 谷歌原生DocumentUI文件浏览的原理

    相信多数想了解谷歌DocumentUI设计思想的码农都会遇到障碍 xff0c 文件浏览究竟是怎么实现的 xff0c 进入DocumentUI的UI层 xff0c 不难发现 xff0c 我们是通过查询数据库获取cursor xff0c 但是查
  • linux下快速查找文件

    版权声明 xff1a 本文为博主xxt 测试开发之路的原创文章 xff0c 遵循 CC 4 0 BY SA 版权协议 xff0c 转载请附上原文出处链接和本声明 本文链接 xff1a https blog csdn net xxmonsto
  • Android 多语言对照表

    语言地区文件夹名称南非荷兰语南非values af rNA南非荷兰语纳米比亚values af rZA阿肯语加纳values ak rGH阿姆哈拉语埃塞俄比亚values am rET阿拉伯语阿拉伯联合酋长国values ar rAE阿拉伯
  • android图片轮播+点击跳转广告页面

    Android轮播网络图片 43 点击跳转广告页面 一些新手总是很头疼怎么获取网络图片的url之后让它像一些广告那样轮播起来 xff0c 点击图片之后跳转到指定网页 效果如下 在布局引用自定义控件 span class hljs pi lt
  • 用SurfaceView实现级联分层图(粗略篇)

    先看效果图 实际运行很流畅 xff0c 运行内存1M左右 最近脑抽 xff0c 想实现一个亲戚关系图谱的应用 xff0c 但始终没有找到合适的开源控件 xff0c 于是就看到一篇 利用递归算法和堆栈实现android思维导图大纲图的动态绘制
  • Android各种访问权限Permission详解

    在Android的设计中 xff0c 资源的访问或者网络连接 xff0c 要得到这些服务都需要声明其访问权限 xff0c 否则将无法正常工作 在Android中这样的权限有很多种 xff0c 这里将各类访问权限一一罗列出来 xff0c 供大
  • 桌面远程连接Ubuntu图形界面和开启ssh连接

    1 xff0c 设置Ubuntu为可被远程连接 Settings Sharing Screen Sharing Access Options设置一个远程连接的密码 连接远程是的密码 xff0c 区别于用户密码 2 xff0c 安装支持vnc
  • Android动态设置Shape

    有过一些开发经验的朋友 xff0c 在做圆角按钮的背景时可能不再需要 9的切图了 xff0c 而一般都是在drawable文件夹下面建立一个xml文件shape 其他状态不变色 或者selector 按下 选中状态变色 xff0c 但是如果
  • Android 禁止锁屏或黑屏

    转载请注明出处 xff1a http blog csdn net snailbaby soko article details 56842467 场景 xff1a 通常情况我们使用的 app 都不需要用到这个功能 但一些平板的开发就很常见了
  • Android 美团Robust热更新 使用入门

    转载请注明出处 http blog csdn net snailbaby soko article details 69524380 本篇文章已授权微信公众号 guolin blog xff08 郭霖 xff09 独家发布 Android热
  • Android 实战-版本更新(okhttp3、service、notification)

    转发请注明出处 http www jianshu com p b669940c9f3e 前言 整理功能 xff0c 把这块拿出来单独做个demo xff0c 好和大家分享交流一下 版本更新这个功能一般 app 都有实现 xff0c 而用户获
  • spark mllib源码分析之二分类逻辑回归的评价指标

    在逻辑回归分类中 xff0c 我们评价分类器好坏的主要指标有精准率 xff08 precision xff09 xff0c 召回率 xff08 recall xff09 xff0c F measure xff0c AUC等 xff0c 其中
  • AB升级之odex文件首次开机处理

    开启AB升级方案的项目 xff0c 因为很多需要升级的镜像都有两份 xff0c 所以存储空间比较浪费 为缓解此问题 xff0c 有个针对odex的优化方案 编译版本会生成两个system镜像 xff1a system img和system
  • Android Bluetooth HCI log 详解

    0 引子 对于蓝牙开发者来说 xff0c 通过HCI log可以帮助我们更好地分析问题 xff0c 理解蓝牙协议 xff0c 就好像网络开发一定要会使用Wireshark分析网络协议一样 本篇主要介绍HCI log的作用 如何抓取一份HCI
  • imx6ull开发板调试nfs环境配置+运行hello程序

    20210314 43 imx6ull开发板nfs环境配置 1 设置git邮箱和用户名 wang 64 wang virtual machine git config global user name 34 snaking616 34 wa
  • 网络编程6:线程池简介

    1 线程池相关结构体 struct threadpool t pthread mutex t lock 用于锁住本结构体 pthread mutex t thread counter 记录忙状态线程个数de琐 busy thr num pt