Python閉包與多線程
来源:互联网 发布:34周b超数据判断男女 编辑:程序博客网 时间:2024/05/17 22:13
I had my position transferred for more than one week from Mobile Security to Clean Master, and have a chance to make a framework to transfer data from one database to another, also some annoying jobs are still in my hand.
Taking the benefits of the Internet and some my old projects, it's easy to frame a framework. Using multi-thread multi-process to do this.
I would like to share that a problem when I try to put an closure inside the thread pool.
code just like this.
def wrap(): a = [0] def init_th(): using a here... a[0] += 1 return init_thdef work(init_th): init_th() .... returnthreading.Thread(target=work, arg=(wrap(), ))
As a result, it comes with the thread safety problem. needs a mutex for the init_th.
In fact, I suddenly know that the GIL never make the thread safety, it just remove some basic problems and make it safe in line-level.
- Python閉包與多線程
- Python
- Python
- Python
- python
- Python
- PYTHON
- Python
- Python
- Python
- Python
- Python
- Python
- Python
- Python
- Python
- Python
- python
- Axis2 and CXF的比较
- Can't find bundle for base name Message, locale zh_CN
- Ubuntu 下搭建 Android 开发环境(图文)
- VS2010中QtService开发环境搭建
- Struts+Spring+Hibernate练习(完整)
- Python閉包與多線程
- xml学习(6) 在c#Xpath实例
- RMI与RPC的区别
- 众筹模式兴起 互联网金融第三波热潮
- LeetCode 之 Median of Two Sorted Arrays
- VC程序的安装与部署安装项目版-一个简单例子
- 如何配置eth0
- Js中 关于top、clientTop、scrollTop、offsetTop的用法
- 谷歌C++编程风格指南