关于 pthreads 版本 3 的 Thread 类的 Pthreads::kill() 的替代方法是啥

     2023-02-16     120

关键词:

【中文标题】关于 pthreads 版本 3 的 Thread 类的 Pthreads::kill() 的替代方法是啥【英文标题】:What's alternate for Pthreads::kill() about Thread class of pthreads version 3关于 pthreads 版本 3 的 Thread 类的 Pthreads::kill() 的替代方法是什么 【发布时间】:2022-01-05 09:52:12 【问题描述】:

kill() 方法已从 PECL pthreads 库版本 3 中删除。

参见存档手册: https://web.archive.org/web/20210410123359/https://www.php.net/manual/en/thread.kill.php

警告:此方法已在 pthreads v3 中删除。 警告:程序员通常不应该强行杀死线程。

所以你可以看到在新版本中被删除: https://www.php.net/manual/en/class.thread.php

现在,从 Thread 类开始的类外终止或终止进程的替代方法是什么?

【问题讨论】:

【参考方案1】:

别无选择。删除此方法正是因为使用 pthreads 杀死这样的线程是不安全的。检查 pthreads 存储库中的 this 和 this 问题以获取更多详细信息和可能的解决方法。

由于 pthreads 已停产,我建议切换到新的 parallel 扩展。它有一个kill 方法。

【讨论】:

C ++中std :: thread优于pthread的优势[重复]

】C++中std::thread优于pthread的优势[重复]【英文标题】:Advantageofstd::threadoverpthreadinC++[duplicate]【发布时间】:2015-09-1420:45:58【问题描述】:我见过使用pthread用C++编写多线程程序的代码以及使用std::thread库的其他代码。用线程库代替... 查看详情

使用 MinGw 编译最新版本的 CppUTest (3.7),缺少 pthreads

】使用MinGw编译最新版本的CppUTest(3.7),缺少pthreads【英文标题】:CompilinglatestreleaseofCppUTest(3.7)withMinGw,pthreadsmissing【发布时间】:2015-11-3004:31:43【问题描述】:我正在尝试在Windows中使用CppUTest,第一步是让它工作,但我已经遇到... 查看详情

我如何理解pthread_create内存使用情况?(代码片段)

这是代码示例它创建了一个独立的pthread#include<stdio.h>#include<unistd.h>#include<pthread.h>void*show_message(void*ptr)char*message;message=(char*)ptr;printf("[%s]start",message);intx=3;for(x=3;x>0;--x)printf("%s",message);sleep(2);printf("[%s]end",message);intcrea... 查看详情

pthread库实现简单并行程序:hello(代码片段)

头文件pthread.h获取线程数量:将字符串转化为10进制数代码:thread_count=strtol(argv[1],NULL,10);其语法格式为:longstrtol(constchar*number_p//in,输入字符char**end_p//out,结束intbase//in);进制数,我们的程序转化为10进制数字显示启动线程显示地启... 查看详情

在 std::thread 创建的线程中调用 pthread_sigmask 是一种好习惯吗?

】在std::thread创建的线程中调用pthread_sigmask是一种好习惯吗?【英文标题】:Isitagoodpracticetocallpthread_sigmaskinathreadcreatedbystd::thread?【发布时间】:2019-02-2516:54:37【问题描述】:1)我是std::thread的新手,我想知道调用pthread_sigmask()来... 查看详情

关键字:__thread&pthread_key_t

  在说__thread之前,先来看看pthread_ket_t吧。  参考:http://blog.csdn.net/lmh12506/article/details/8452700  上面的博文说的比较通俗易懂。线程私有数据可以理解为线程内的全局变量。在线程内可以被所有函数访问,但是不能被其他... 查看详情

C Linux 中的 Pthread 信令

】CLinux中的Pthread信令【英文标题】:PthreadsignallinginCLinux【发布时间】:2019-09-1202:04:57【问题描述】:我正在使用Pthread在Linux中处理多线程。Thread1通过轮询字符设备文件来等待来自驱动程序的IRQ(我的驱动程序有ISR来从硬件捕获... 查看详情

一旦std:thread进入C ++ Ox,pthreads是不是会过时[关闭]

】一旦std:thread进入C++Ox,pthreads是不是会过时[关闭]【英文标题】:Willpthreadsbecomeobsoleteoncestd:threadmakesintoC++Ox[closed]一旦std:thread进入C++Ox,pthreads是否会过时[关闭]【发布时间】:2009-08-1317:52:17【问题描述】:显然我们仍然会维... 查看详情

使用 native_handle() + pthread_cancel() 取消 std::thread

】使用native_handle()+pthread_cancel()取消std::thread【英文标题】:cancellingstd::threadusingnative_handle()+pthread_cancel()【发布时间】:2012-11-2314:40:03【问题描述】:我正在将先前围绕pthreads的线程包装器转换为std::thread。但是c++11没有任何方法... 查看详情

具有多个 Pthread 的 MPI

】具有多个Pthread的MPI【英文标题】:MPIwithMultiplePthreads【发布时间】:2016-08-0211:39:02【问题描述】:我正在使用以下代码段为多个线程初始化mpi库。但是我总是得到以下输出,说这个MPI实现不支持MPI_THREAD_MULTIPLE。MPI_Init_thread(&... 查看详情

pthread_join的介绍

参考技术A函数pthread_join用来等待一个线程的结束。头文件:#include&lt;pthread.h&gt;函数定义:intpthread_join(pthread_tthread,void**retval);描述:pthread_join()函数,以阻塞的方式等待thread指定的线程结束。当函数返回时,被等待线程的... 查看详情

linux pthreads 上的 gcc 4.7 - 使用 __thread 的重要 thread_local 解决方法(无提升)

】linuxpthreads上的gcc4.7-使用__thread的重要thread_local解决方法(无提升)【英文标题】:gcc4.7onlinuxpthreads-nontrivialthread_localworkaroundusing__thread(noboost)【发布时间】:2012-08-2106:51:06【问题描述】:在C++11中,您可以拥有一个具有thread_loca... 查看详情

pthread学习笔记

POSIX线程,也被称为Pthreads,是一个线程的POSIX标准;pthread.hintpthread_create(pthread_t*thread, pthread_attr_tconst*attr, void*(*start_routine)(void*), void*arg);thread:新线程句柄attr:新线程属性start_routine:线程启动程序arg:线程启动程序参数 查看详情

pthread_cancel相关

...A对线程B发出了一个取消请求。通过如下函数:#include<pthread.h>intpthread_cancel(pthread_tthread);参数:thread-收到取消请求的线程id返回值:发送终止信号给thread线程,如果成功则返回0,否则为非0值。发送成功并不意味着thread会终... 查看详情

1.多线程编程(代码片段)

...例程,给自己写一些关于多线程编程的API的笔记目录pthread1.c pthread2.cpthread3.cpthread4.c pthread5.cpthread1.c#include<pthread.h>#include<stdio.h>#include<unistd.h>staticvoid*my_thread_func(void*data) while(1) sleep(1); intmain(intargc,char**argv) pthr... 查看详情

testforthreadlocalstorage(代码片段)

#include<iostream>#include<pthread.h>#include<unistd.h>usingnamespacestd;//__threadintiVar=100;intiVar=100;void*thread1(void*arg)iVar+=200;cout<<"thread1val:"<<iVar<<endl;void*thread2(void*arg)iVar+=400;sleep(1);cout<<"thr... 查看详情

/include/boost/thread/pthread/mutex.hpp:111: boost::mutex::~mutex(): Assertion `!res' 失败

】/include/boost/thread/pthread/mutex.hpp:111:boost::mutex::~mutex():Assertion`!res\\\'失败【英文标题】:/include/boost/thread/pthread/mutex.hpp:111:boost::mutex::~mutex():Assertion`!res\'failed/include/boost/thread/pthread/mutex. 查看详情

php pthreads安装问题与php

】phppthreads安装问题与php【英文标题】:PHPpthreadsinstallationproblemwithphp【发布时间】:2019-12-0209:03:20【问题描述】:我使用PHP5.6.40,尝试安装php_threads2.0.10。我关注主题PHPpthreads:Fatalerror:Class\'Thread\'notfound我使用wampserver。Apache版本... 查看详情