基于线程池模型的讨论与完整代码演示

2023-11-13


线程池引入的必要性:

在网络服务器中,包括大量的web服务器,它们都需要在单位时间内必须处理相当数目的接入请求以及数据处理。通常在传统多线程服务器中是这样实现的:一旦有个请求到达,就创建一个线程,由该线程执行任务,任务执行完毕后,线程就退出。这也就是通常所说的及时创建,及时销毁策略。在现代计算机中,尽管创建线程的时间已经大大缩短,但是如果提交给线程的任务是执行时间较短,而且次数非常的频繁,那么服务器就将处于一个不停创建于销毁线程的状态下,这将是一笔不小的开销。尤其是在线程执行的时间非常短的情况。

线程池就是为了解决上述问题的。

线程池概念 

它的实现原理是这样的:在应用程序启动之后,就马上创建一定数量的线程,放入空闲的队列中。这些线程都是处于阻塞状态,这些线程只占一点内存,不占用CPU。当任务到来后,线程池将选择一个空闲的线程,将任务传入此线程中运行。当所有的线程都处在处理任务的时候,线程池将自动创建一定的数量的新线程,用于处理更多的任务。执行任务完成之后线程并不退出,而是继续在线程池中等待下一次任务。当大部分线程处于阻塞状态时,线程池将自动销毁一部分的线程,回收系统资源。

下面是一个简单线程池的实现,这个线程池的代码是我从网上的一个例子参考到的,程序的整体方案是这样的:程序启动之前,初始化线程池,启动线程池中的线程,由于还没有任务到来,线程池中的所有线程都处在阻塞状态,当一有任务到达就从线程池中取出一个空闲线程处理,如果所有的线程都处于工作状态,就添加到队列,进行排队。如果队列中的任务个数大于队列的所能容纳的最大数量,那就不能添加任务到队列中,只能等待队列不满才能添加任务到队列中。

本程序由三个文件组成,分别是threadpoll.h,threadpoll.c,main.c,下面的代码已经在64位系统成功运行。

 

验证环境:

 

Distributor ID: Ubuntu

Description: Ubuntu 13.04

Release: 13.04

Codename: raring

 

线程池代码示例

threadpoll.h文件下的代码

#ifndef _THREADPOLL_H_
#define _THREADPOLL_H_
#include<pthread.h>
#include<unistd.h>
#include<stdlib.h>
#include<assert.h>
struct job
{
    void* (*callback_function)(void *arg);    //线程回调函数
    void *arg;                               //回调函数参数
    struct job *next;
};

struct threadpool
{
    int thread_num;                   //线程池中开启线程的个数
    int queue_max_num;                //队列中最大job的个数
    struct job *head;                 //指向job的头指针
    struct job *tail;                 //指向job的尾指针
    pthread_t *pthreads;              //线程池中所有线程的pthread_t
    pthread_mutex_t mutex;            //互斥信号量
    pthread_cond_t queue_empty;       //队列为空的条件变量
    pthread_cond_t queue_not_empty;   //队列不为空的条件变量
    pthread_cond_t queue_not_full;    //队列不为满的条件变量
    int queue_cur_num;                //队列当前的job个数
    int queue_close;                  //队列是否已经关闭
    int pool_close;                   //线程池是否已经关闭
};
//===================================================================
//函数名:                   threadpool_init
//函数描述:                 初始化线程池
//输入:                    [in] thread_num     线程池开启的线程个数
//                         [in] queue_max_num  队列的最大job个数 
//输出:                    无
//返回:                    成功:线程池地址 失败:NULL
//===================================================================
struct threadpool* threadpool_init(int thread_num, int queue_max_num);

//===================================================================
//函数名:                    threadpool_add_job
//函数描述:                  向线程池中添加任务
//输入:                     [in] pool                  线程池地址
//                          [in] callback_function     回调函数
//                          [in] arg                     回调函数参数
//输出:                     无
//返回:                     成功:0 失败:-1
//==================================================================
int threadpool_add_job(struct threadpool *pool, void* (*callback_function)(void *arg), void *arg);

//===================================================================
//函数名:                    threadpool_destroy
//函数描述:                   销毁线程池
//输入:                      [in] pool                  线程池地址
//输出:                      无
//返回:                      成功:0 失败:-1
//===================================================================
int threadpool_destroy(struct threadpool *pool);

//===================================================================
//函数名:                    threadpool_function
//函数描述:                  线程池中线程函数
//输入:                     [in] arg                  线程池地址
//输出:                     无  
//返回:                     无
//===================================================================
void* threadpool_function(void* arg);
#endif



threadpoll.c

#include "threadpoll.h"
#include<stdio.h>
struct threadpool* threadpool_init(int thread_num, int queue_max_num)
{
    struct threadpool *pool = NULL;
    do
    {
        pool = malloc(sizeof(struct threadpool));
        if (NULL == pool)
        {
            printf("failed to malloc threadpool!\n");
            break;
        }
        pool->thread_num = thread_num;
        pool->queue_max_num = queue_max_num;
        pool->queue_cur_num = 0;
        pool->head = NULL;
        pool->tail = NULL;
        if (pthread_mutex_init(&(pool->mutex), NULL))
        {
            printf("failed to init mutex!\n");
            break; 
        }    
        if (pthread_cond_init(&(pool->queue_empty), NULL))
        {
            printf("failed to init queue_empty!\n");
            break;
        }
        if (pthread_cond_init(&(pool->queue_not_empty), NULL))
        {
            printf("failed to init queue_not_empty!\n");
            break;
        }
        if (pthread_cond_init(&(pool->queue_not_full), NULL))
        {
            printf("failed to init queue_not_full!\n");
            break;
        }
        pool->pthreads = malloc(sizeof(pthread_t) * thread_num);
        if (NULL == pool->pthreads)
        {
            printf("failed to malloc pthreads!\n");
            break;
        }
        pool->queue_close = 0;
        pool->pool_close = 0;
        int i;
        for (i = 0; i < pool->thread_num; ++i)
        {
            pthread_create(&(pool->pthreads[i]), NULL, threadpool_function, (void *)pool);
        }

        return pool;
    } while (0);

    return NULL;
}
int threadpool_add_job(struct threadpool* pool, void* (*callback_function)(void *arg), void *arg)
{
    assert(pool != NULL);
    assert(callback_function != NULL);
    assert(arg != NULL);

    pthread_mutex_lock(&(pool->mutex));
    while ((pool->queue_cur_num == pool->queue_max_num) && !(pool->queue_close || pool->pool_close))
    {
        pthread_cond_wait(&(pool->queue_not_full), &(pool->mutex));   //队列满的时候就等待
    }
    if (pool->queue_close || pool->pool_close)    //队列关闭或者线程池关闭就退出
    {
        pthread_mutex_unlock(&(pool->mutex));
        return -1;
    }
    struct job *pjob =(struct job*) malloc(sizeof(struct job));
    if (NULL == pjob)
    {
        pthread_mutex_unlock(&(pool->mutex));
        return -1;
    }
    pjob->callback_function = callback_function;
    pjob->arg = arg;
    pjob->next = NULL;
    if (pool->head == NULL)
    {
        pool->head = pool->tail = pjob;
        pthread_cond_broadcast(&(pool->queue_not_empty)); 

       //队列空的时候,有任务来时就通知线程池中的线程:队列非空
    }
    else
    {
        pool->tail->next = pjob;
        pool->tail = pjob;
    }
    pool->queue_cur_num++;
    pthread_mutex_unlock(&(pool->mutex));
    return 0;
}
void* threadpool_function(void* arg)
{
    struct threadpool *pool = (struct threadpool*)arg;
    struct job *pjob = NULL;
    while (1)  //死循环
    {
        pthread_mutex_lock(&(pool->mutex));
        while ((pool->queue_cur_num == 0) && !pool->pool_close)   //队列为空时,就等待队列非空
        {
            pthread_cond_wait(&(pool->queue_not_empty), &(pool->mutex));
        }
        if (pool->pool_close)   //线程池关闭,线程就退出
        {
            pthread_mutex_unlock(&(pool->mutex));
            pthread_exit(NULL);
        }
        pool->queue_cur_num--;
        pjob = pool->head;
        if (pool->queue_cur_num == 0)
        {
            pool->head = pool->tail = NULL;
        }
        else
        {
            pool->head = pjob->next;
        }
        if (pool->queue_cur_num == 0)
        {
            pthread_cond_signal(&(pool->queue_empty));      
         //队列为空,就可以通知threadpool_destroy函数,销>毁线程函数
        }
             }
        if (pool->queue_cur_num == pool->queue_max_num - 1)
        {
            pthread_cond_broadcast(&(pool->queue_not_full));  //队列非满,就可以通知threadpool_add_job函数,添>加新任务
        }
        pthread_mutex_unlock(&(pool->mutex));

        (*(pjob->callback_function))(pjob->arg);   //线程真正要做的工作,回调函数的调用
        free(pjob);
        pjob = NULL;
    }
}        
int threadpool_destroy(struct threadpool *pool)
{
    assert(pool != NULL);
    pthread_mutex_lock(&(pool->mutex));
    if (pool->queue_close || pool->pool_close)   //线程池已经退出了,就直接返回
    {
        pthread_mutex_unlock(&(pool->mutex));
        return -1;
    }

    pool->queue_close = 1;        //置队列关闭标志
    while (pool->queue_cur_num != 0)
    {
        pthread_cond_wait(&(pool->queue_empty), &(pool->mutex));  //等待队列为空
    }

    pool->pool_close = 1;      //置线程池关闭标志
    pthread_mutex_unlock(&(pool->mutex));
    pthread_cond_broadcast(&(pool->queue_not_empty));  //唤醒线程池中正在阻塞的线程
    pthread_cond_broadcast(&(pool->queue_not_full));   //唤醒添加任务的threadpool_add_job函数
    int i;
    for (i = 0; i < pool->thread_num; ++i)
    {
        pthread_join(pool->pthreads[i], NULL);    //等待线程池的所有线程执行完毕
    }

    pthread_mutex_destroy(&(pool->mutex));          //清理资源
    pthread_cond_destroy(&(pool->queue_empty));
    pthread_cond_destroy(&(pool->queue_not_empty));
    pthread_cond_destroy(&(pool->queue_not_full));
    free(pool->pthreads);
    struct job *p;
while (pool->head != NULL) 
    {
        p = pool->head;
        pool->head = p->next;
        free(p);
    }
    free(pool);
    return 0;
}                                          

main.c

#include<stdio.h>
#include"threadpoll.h"
void* work(void* arg)
{
    char *p = (char*) arg;
    printf("threadpool callback fuction : %s.\n", p);
    sleep(1);
}
int main(void)
{
    struct threadpool *pool = threadpool_init(10, 20);
    threadpool_add_job(pool, work, "1");
    threadpool_add_job(pool, work, "2");
    threadpool_add_job(pool, work, "3");
    threadpool_add_job(pool, work, "4");
    threadpool_add_job(pool, work, "5");
    threadpool_add_job(pool, work, "6");
    threadpool_add_job(pool, work, "7");
    threadpool_add_job(pool, work, "8");
    threadpool_add_job(pool, work, "9");
    threadpool_add_job(pool, work, "10");
    threadpool_add_job(pool, work, "11");
    threadpool_add_job(pool, work, "12");
    threadpool_add_job(pool, work, "13");
    threadpool_add_job(pool, work, "14");
    threadpool_add_job(pool, work, "15");
    threadpool_add_job(pool, work, "16");
    threadpool_add_job(pool, work, "17");
    threadpool_add_job(pool, work, "18");
    threadpool_add_job(pool, work, "19");
    threadpool_add_job(pool, work, "20");
    threadpool_add_job(pool, work, "21");
    threadpool_add_job(pool, work, "22");
    threadpool_add_job(pool, work, "23");
    threadpool_add_job(pool, work, "24");
    threadpool_add_job(pool, work, "25");
    threadpool_add_job(pool, work, "26");
    threadpool_add_job(pool, work, "27");
    threadpool_add_job(pool, work, "28");
    threadpool_add_job(pool, work, "29");
    threadpool_add_job(pool, work, "30");
    threadpool_add_job(pool, work, "31");
    threadpool_add_job(pool, work, "32");
    threadpool_add_job(pool, work, "33");
    threadpool_add_job(pool, work, "34");
    threadpool_add_job(pool, work, "35");
    threadpool_add_job(pool, work, "36");
    threadpool_add_job(pool, work, "37");
    threadpool_add_job(pool, work, "38");
    threadpool_add_job(pool, work, "39");
    threadpool_add_job(pool, work, "40");

    sleep(5);
    threadpool_destroy(pool);
    return 0;
}                                                          

gcc main.c threadpoll.c -lpthread -othreadpoll

 

./threadpoll


ky@ky-S910-X31E:~/libz/623$ ./threadpoll
threadpool callback fuction : 1.
threadpool callback fuction : 2.
threadpool callback fuction : 8.
threadpool callback fuction : 5.
threadpool callback fuction : 3.
threadpool callback fuction : 13.
threadpool callback fuction : 6.
threadpool callback fuction : 17.
threadpool callback fuction : 18.
threadpool callback fuction : 19.
threadpool callback fuction : 20.
threadpool callback fuction : 21.
threadpool callback fuction : 22.
threadpool callback fuction : 23.
threadpool callback fuction : 24.
threadpool callback fuction : 25.
threadpool callback fuction : 26.
threadpool callback fuction : 27.
threadpool callback fuction : 28.
threadpool callback fuction : 29.
threadpool callback fuction : 30.
threadpool callback fuction : 31.
threadpool callback fuction : 32.
threadpool callback fuction : 33.
threadpool callback fuction : 34.
threadpool callback fuction : 35.
threadpool callback fuction : 36.
threadpool callback fuction : 37.
threadpool callback fuction : 38.
threadpool callback fuction : 39.
threadpool callback fuction : 40.
threadpool callback fuction : 9.
threadpool callback fuction : 11.
threadpool callback fuction : 12.
threadpool callback fuction : 14.
threadpool callback fuction : 7.
threadpool callback fuction : 15.
threadpool callback fuction : 16.
threadpool callback fuction : 10.
threadpool callback fuction : 4.



更多内容请前往:

http://wenku.baidu.com/p/helpylee


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

基于线程池模型的讨论与完整代码演示 的相关文章

  • 计算 XML 中特定 XML 节点的数量

    请参阅此 XML
  • ubuntu 16.04.1 LTS 启动 Android 模拟器时崩溃

    我已经尝试过 Android studio 上的 AVD 和 Genymotion 模拟器 我的 ubuntu 16 04 1 在启动 android 模拟器时崩溃 冻结 我的电脑内存是16G 在我于 2016 年 9 月 19 日安装了
  • 在c#中执行Redis控制台命令

    我需要从 Redis 控制台获取 客户端列表 输出以在我的 C 应用程序中使用 有没有办法使用 ConnectionMultiplexer 执行该命令 或者是否有内置方法可以查找该信息 CLIENT LIST是 服务器 命令 而不是 数据库
  • 查找进程的完整路径

    我已经编写了 C 控制台应用程序 当我启动应用程序时 不使用cmd 我可以看到它列在任务管理器的进程列表中 现在我需要编写另一个应用程序 在其中我需要查找以前的应用程序是否正在运行 我知道应用程序名称和路径 所以我已将管理对象搜索器查询写入
  • 为什么在 WebApi 上下文中在 using 块中使用 HttpClient 是错误的?

    那么 问题是为什么在 using 块中使用 HttpClient 是错误的 但在 WebApi 上下文中呢 我一直在读这篇文章不要阻止异步代码 https blog stephencleary com 2012 07 dont block
  • Python 属性和 Swig

    我正在尝试使用 swig 为一些 C 代码创建 python 绑定 我似乎遇到了一个问题 试图从我拥有的一些访问器函数创建 python 属性 方法如下 class Player public void entity Entity enti
  • 将 Long 转换为 DateTime 从 C# 日期到 Java 日期

    我一直尝试用Java读取二进制文件 而二进制文件是用C 编写的 其中一些数据包含日期时间数据 当 DateTime 数据写入文件 以二进制形式 时 它使用DateTime ToBinary on C 为了读取 DateTime 数据 它将首
  • 打破 ReadFile() 阻塞 - 命名管道 (Windows API)

    为了简化 这是一种命名管道服务器正在等待命名管道客户端写入管道的情况 使用 WriteFile 阻塞的 Windows API 是 ReadFile 服务器已创建启用阻塞的同步管道 无重叠 I O 客户端已连接 现在服务器正在等待一些数据
  • 在 NaN 情况下 to_string() 可以返回什么

    我使用 VS 2012 遇到了非常令人恼火的行为 有时我的浮点数是 NaN auto dbgHelp std to string myFloat dbgHelp最终包含5008角色 你不能发明这个东西 其中大部分为0 最终结果是 0 INF
  • Tomcat 6找不到mysql驱动

    这里有一个类似的问题 但关于类路径 ClassNotFoundException com mysql jdbc Driver https stackoverflow com questions 1585811 classnotfoundex
  • 在mysql连接字符串中添加应用程序名称/程序名称[关闭]

    Closed 这个问题需要细节或清晰度 help closed questions 目前不接受答案 我正在寻找一种解决方案 在连接字符串中添加应用程序名称或程序名称 以便它在 MySQL Workbench 中的 客户端连接 下可见 SQL
  • 检测到严重错误 c0000374 - C++ dll 将已分配内存的指针返回到 C#

    我有一个 c dll 它为我的主 c 应用程序提供一些功能 在这里 我尝试读取一个文件 将其加载到内存 然后返回一些信息 例如加载数据的指针和内存块的计数到 c Dll 成功将文件读取到内存 但在返回主应用程序时 程序由于堆损坏而崩溃 检测
  • WebBrowser.Print() 等待完成。 。网

    我在 VB NET 中使用 WebBrowser 控件并调用 Print 方法 我正在使用 PDF 打印机进行打印 当调用 Print 时 它不会立即启动 它会等到完成整个子或块的运行代码 我需要确保我正在打印的文件也完整并继续处理该文件
  • C++ new * char 不为空

    我有一个问题 我在 ASIO 中开发服务器 数据包采用尖头字符 当我创建新字符时 例如char buffer new char 128 我必须手动将其清理为空 By for int i 0 i lt 128 i buffer i 0x00
  • 在 Windows Phone silverlight 8.1 上接收 WNS 推送通知

    我有 Windows Phone 8 1 silverlight 应用程序 我想使用新框架 WNS 接收通知 我在 package appxmanifest 中有
  • 堆栈是向上增长还是向下增长?

    我在 C 中有这段代码 int q 10 int s 5 int a 3 printf Address of a d n int a printf Address of a 1 d n int a 1 printf Address of a
  • 我可以在“字节数”设置为零的情况下调用 memcpy() 和 memmove() 吗?

    当我实际上没有什么可以移动 复制的时候 我是否需要处理这些情况memmove memcpy 作为边缘情况 int numberOfBytes if numberOfBytes 0 memmove dest source numberOfBy
  • 如何减少具有多个单元的 PdfPTable 的内存消耗

    我正在使用 ITextSharp 创建一个 PDF 它由单个 PdfTable 组成 不幸的是 对于特定的数据集 由于创建了大量 PdfPCell 我遇到了内存不足异常 我已经分析了内存使用情况 我有近百万个单元格的 1 2 在这种情况下有
  • 如何使用 C++11 using 语法键入定义函数指针?

    我想写这个 typedef void FunctionPtr using using 我该怎么做呢 它具有类似的语法 只不过您从指针中删除了标识符 using FunctionPtr void 这是一个Example http ideone
  • 如何将十六进制字符串转换为无符号长整型?

    我有以下十六进制值 CString str str T FFF000 如何将其转换为unsigned long 您可以使用strtol作用于常规 C 字符串的函数 它使用指定的基数将字符串转换为 long long l strtol str

随机推荐

  • Hbase Shell操作

    文章目录 Hbase Shell操作 1 创建表 2 数据库表基本操作 2 1 添加数据 2 2 删除数据 2 2 1 delete命令 2 2 2 deleteall命令 2 3 查看数据 2 3 1 get命令 2 3 2 scan命令
  • 【Twinkle】Chrome快捷键是真的好用

    1 标签页和窗口快捷键 快捷键 说明 Ctrl n 打开新窗口 Ctrl shift n 在隐身模式下打开新窗口 Ctrl t 打开新的标签页 常用 Ctrl Shift t 重新打开最后关闭的标签页 Ctrl Tab 或 Ctrl Pgd
  • java聊天室的设计与实现代码

    聊天室是一个简单的通信应用 可以帮助您与客户和朋友保持联系 并且可以让您更轻松地与其他员工联系 然而 您将不得不确保每个人都知道他们正在做什么 一旦聊天室开始 它就会变得非常复杂 因为有许多用户可能会同时登录 例如 如果您有一个新的工作机会
  • openGL之API学习(六十二)glBufferData

    往gpu缓冲区写入数据 void glBufferData GLenum target GLsizeiptr size const GLvoid data GLenum usage target Specifies the target t
  • 用redis作为消息推送

    1首先写配置监听文件 Configuration EnableCaching public class RestRedisConfig extends CachingConfigurerSupport Value redis server
  • java.awt GUI报错及相关问题解决方案

    Caused by java awt HeadlessException No X11 DISPLAY variable was set but this program performed an operation which requi
  • CLIP-as-service 升级啦!

    CLIP 是一个强大的模型 能够很好地判别文本和图片是否相关 但将其集成到现有系统中需要大量时间精力 以及机器学习知识 CLIP as service CAS 是一种易于使用的服务 具有低延迟和高度可扩展性 可以作为微服务轻松集成到现有解决
  • QT 如何复制与粘贴?(QClipboard)

    这里用QMenu菜单栏来展示示例一下 QMenu m ProgramBtnGroupMenu QAction m CopyEffectAction 添加操作 m ProgramBtnGroupMenu new QMenu this m Pr
  • pip 和 conda 的联系区别、安装包方法、换源方法

    pip 和 conda 的联系与区别 pip 是 Python 包管理工具 conda 是一个开源的软件包管理系统和环境管理系统 pip 对Python包进行管理 而 conda 不仅能进行包管理 还能够创建隔离的环境 该环境可以包含不同版
  • 查看隐藏文件怎么做?4个简单方法分享

    朋友们 想问问大家如果设置了隐藏文件 想查看的时候应该怎么进行查看呀 有没有朋友可以教教我 为了保护电脑的隐私 我们有时候可能会给电脑设置某些隐藏的文件 这些隐藏的文件我们是无法看到的 如果我们想查看隐藏的文件应该怎么查看呢 本文小编将给大
  • 复制即可用!C语言读取文件所有内容 并输出,c语言将浏览器网页cookie转为json格式,c语言将网页cookie转为python的webdriver.add_cookie()参数所需格式

    C语言读取文件所有内容并输出 c语言将浏览器网页cookie转为json格式 c语言将网页cookie转为python的webdriver add cookie 参数所需格式 代码在下方 复制即可用 运行结果截图 转化出的普通json格式结
  • Springboot框架整合Spring Data JPA操作数据

    一 Sping Data JPA 简介 Spring Data JPA 是 Spring 基于 ORM 框架 JPA 规范的基础上封装的一套 JPA 应用框架 底层使用了 Hibernate 的 JPA 技术实现 可使开发者用极简的代码即可
  • 如何学习软件测试

    软件测试是确保软件质量的重要手段 在现代软件开发中 软件测试已经成为了必不可少的一环 因为它可以发现并纠正软件中的缺陷和错误 从而提高软件的可靠性 可用性和安全性 因此 学习软件测试对于想要从事或已经从事软件开发的人来说是非常重要的 以下是
  • springboot同时引入mysql5和mysql8,多数据源驱动解决方案

    springboot项目需要配置多数据源 同时引入mysql5和mysql8的时候 框架默认8版本的驱动 调用从库mysql5是会报驱动错误 CLIENT PLUGIN AUTH is required 解决办法 首先明确 mysql8配置
  • Qt_如何关联头文件、源文件和ui文件?

    1 头文件与源文件 首先头文件和源文件就不多说了 头文件放声明 源文件放定义 2 关于ui文件 我们知道在新建项目的时候 可以选择添加 ui和不添加两种 当添加上ui 文件的时候 我们可以利用designer来添加控件 直观上看到界面的布局
  • 一台windows环境下安装多个MySQL服务

    将第一个安装的MySQL安装文件夹复制一份并重命名 修改my ini的配置文件内容 把第二个MySQL服务配置环境变量 D Program Files MySQL MySQL3307 Server 5 5 bin 添加到系统变量path中
  • gitee的详细使用教程

    文章目录 前言 一 将本地文件上传至gitee仓库中 1 创建本地文件夹 2 将本地文件初始化为本地仓库 3 上传至本地仓库中 1 将文件从工作区存入暂缓区 2 将暂缓区的文件存入本地仓库中 4 还原已删除文件 5 将本地仓库文件上传至gi
  • Android(安卓)上传文件到阿里云点播,阿里云点播转码

    Android 安卓 上传文件到阿里云点播 阿里云点播转码 文章目录 Android 安卓 上传文件到阿里云点播 阿里云点播转码 一 登录阿里云点播平台配置添加转码模板组 1 需要什么参数 可自行填写 然后保存 如图 2 把获取的模板 ID
  • 解决安装mysql与mariadb冲突问题(卸载干净mariadb)

    阿里云服务器 centos7 6 a 查询mariadb libs的包名 rpm qa grep mariadb b 卸载 rpm e mariadb libs 5 5 60 1 el7 5 x86 64 error Failed depe
  • 基于线程池模型的讨论与完整代码演示

    线程池引入的必要性 在网络服务器中 包括大量的web服务器 它们都需要在单位时间内必须处理相当数目的接入请求以及数据处理 通常在传统多线程服务器中是这样实现的 一旦有个请求到达 就创建一个线程 由该线程执行任务 任务执行完毕后 线程就退出