ChinaUnix.net
相关文章推荐:

boost thread获取当前线程

小女子又要向各位前辈请教了~~ 我是用threading.thread继承的方式来创建线程的。比如在主线程中,我让一个子线程用mythread.join()的方式先运行完,之后是不是表示这个子线程已经死了?:em14: 不知Python是不是像C++那样,还需要释放内存空间吗?:em14: 小女子在此先谢谢各位的帮助了!:em18:

by 雪堡的天空 - Python - 2008-07-31 08:38:10 阅读(4035) 回复(11)

相关讨论

这两天把boost 1.35.0中的boost.thread库的文档翻译过来了,有兴趣的看看 发现上次发布的不带书签,现发布一个带书签的 [ 本帖最后由 tyc611 于 2008-6-21 16:53 编辑 ]

by tyc611 - C/C++ - 2008-10-18 15:14:40 阅读(12346) 回复(21)

1. Kernel thread 与 LWP的关系 2. Kernel thread 是怎样实现的 ? 不是简单的说几个函数 3. Unix 怎样调度这些 Kernel thread?

by chenzhanyiczy - C/C++ - 2009-03-13 19:59:57 阅读(2096) 回复(6)

今天看了thread文档,没看明白,可以下面这样用吗? #load use threads; $thr1= threads->new(\&require1); $thr2= threads->new(\&require2); $thr3= threads->new(\&require3); $thr4= threads->new(\&require4); sub require1(){ require("include/t_ad_keyword.pl"); } sub require2(){ require("include/t_media_info.pl"); require("include/t_qeesoo_visitdata.pl"); } sub require3(){ require("include/t_showd...

by 枫影谁用了 - Perl - 2011-04-24 02:19:41 阅读(5561) 回复(20)

1. 多线程 1.1 创建线程类 在Java中可以简单的从thread类中继承创建自己的线程类: public class MyFirstthread extends thread { public void run() { . . .} } 说明: (1) thread类位是java.lang包中,所以可以不用显示import; (2) 从thread类中继承下来的类最好重载run()方法,以运行需要的代码; 可以按以下方法实例化并运行线程: MyFirstthread aMFT = new MyFirstthread(); aMFT.start(); 说明: (3...

by danlley - Java文档中心 - 2006-07-31 15:41:53 阅读(804) 回复(0)

[code] 线程类(thread) @version:1.0 @author:axgle */ $th=new thread(10);//10个线程 $th->exec('demo');//执行自定义的函数 function demo() { fopen('data/'.microtime(),'w'); } class thread { var $count; function thread($count=1) { $this->count=$count; } function _submit() { for($i=1;$i<=$this->count;$i++) $this->_thread(); return true; } ...

by axgle - PHP - 2011-02-16 11:47:22 阅读(26803) 回复(10)

1.boost::thread 库中是否可以产生带有参数的线程,比如现有一个函数:string func(string s),我该如何生成多个线程?且每个线程传入的参数不一样. 2.我用多个线程调用同一个函数,但我想每次调用的函数实现的功能都不一样?比如,线程1和线程2,分别读数据库中的第一条和第二条记录? 我原来想的是在该函数中放一个全局变量,但不知道该如何实现互斥.其代码如下: #include #include <boost/thread/thread.hpp> using namespace...

by oitry_chen - C/C++ - 2008-08-29 22:52:16 阅读(4018) 回复(8)

1 $sem=thread::Semaphor->new(10); 2 用threads->create(\&do,$task)创建7个线程,创建前$sem->down(); 3 在sub do{},中打印日志到文件后调用threads->detach然后$sem->up(); 脚本每分钟添加7个threads 问题是内存会一直缓慢增加,如何回收thread的内存呢???

by huhuegg - Perl - 2009-06-15 11:09:24 阅读(3900) 回复(3)

把之前做的基于 pthread线程池代码,移植到了 windows 平台。 移植方法是在 windows 平台用 Mutex 和 Event 模拟了 pthread_mutex 和 pthread_cond 类型。 和平台相关的内容统一在一个 spthread.h 中。线程池的实现代码中,就不再需要 ifdef 这种东西了。 实现思路的说明: Build a thread pool in C 下载 http://spserver.googlecode.com/files/threadpool-0.2.src.tar.gz [ 本帖最后由 iunknown 于 2008-5-19 14:15 编辑 ]

by iunknown - C/C++ - 2011-04-24 02:14:50 阅读(12678) 回复(16)

我想在初始化线程里取消另外一个线程 并释放该线程占有的资源 应该怎么做 用 pthread_cancle() pthread_join() 可不可以实现 (线程创建时属性是默认的) 再有就是怎么做才会安全的取消这个线程线程里的代码在安全的前提下) 是不是要先加锁 然后取消 最后再解锁

by surfzsl - C/C++ - 2005-04-28 16:15:50 阅读(1529) 回复(6)

下面是参考书上的一个“生产者-消费者”同步程序: //主程序 public class ConProd { public static void main(String args[]) { Buffer buffer=new Buffer(); new thread(new Producer(buffer)).start(); new thread(new Consumer(buffer)).start(); } } //临界资源 class Buffer{ int data; boolean dataready=false; public synchronized int get(){ if (dataready==false){ try{ wait(); } cat...

by matchchen - Java - 2004-09-09 15:02:14 阅读(2205) 回复(2)