需求,有一个IP列表文件 ip.txt,里面有1000个ip,那么我要用python同时来处理这1000个IP。
先看ip.txt
192.168.1.1
192.168.1.2
192.168.1.3
......
192.168.1.1000
多线程并发脚本
#!/usr/bin/python
import threading
import sys
import os
...
分类:
编程语言 时间:
2015-01-24 15:58:24
阅读次数:
144
PHP 5.3 以上版本,使用pthreads PHP扩展,可以使PHP真正地支持多线程。多线程在处理重复性的循环任务,能够大大缩短程序执行时间。在liunx下的安装准备工作:1.下载Threading for PHP安装包https://github.com/krakjoe/pthreads2.p...
分类:
编程语言 时间:
2015-01-22 20:00:28
阅读次数:
473
using AnfleCrawler.Common;using System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Text;using System.Threading.Ta...
分类:
其他好文 时间:
2015-01-22 14:38:14
阅读次数:
135
using AnfleCrawler.Common;using System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Text;using System.Threading.Ta...
分类:
其他好文 时间:
2015-01-22 12:39:35
阅读次数:
190
using System;using System.Threading;class Example{ static void Main() { TimeSpan interval = new TimeSpan(0, 0, 2); for (int i = 0;...
分类:
编程语言 时间:
2015-01-21 22:00:33
阅读次数:
236
1 using System; 2 using System.Collections.Generic; 3 using System.Drawing; 4 using System.Linq; 5 using System.Text; 6 using System.Threading....
替代object加锁方式
使用System.object对象作为线程同步的工具,建立了一个基本的锁机制,确保资源只能同时被一个线程所访问。
但是这个对象不作任何其他用途,知识用于锁机制。
如果有一个类型可以专注于为线程同步的锁机制和信号量机制提供服务,那么上面的代码就可以简化。
.net中提供了更强大的system.threading.wa...
分类:
其他好文 时间:
2015-01-20 22:17:51
阅读次数:
170
首先,来看下使用system.threading.monitor对资源进行保护的思路:
即,使用排它锁,当线程A需要访问某一资源时,对其进行加锁,线程A获取到锁以后,任何其他线程如果再次对资源进行访问,则将其放到等待队列中,知道线程A释放锁之后,再将线程从队列中取出。
主要的两个方法:
Enter
Exit
获取锁
...
分类:
其他好文 时间:
2015-01-20 20:31:34
阅读次数:
144
/* MySql 类 */using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using MySql.Data.MySqlC...
分类:
数据库 时间:
2015-01-19 23:34:21
阅读次数:
294
using System;using System.Collections;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace List...
分类:
编程语言 时间:
2015-01-19 20:54:26
阅读次数:
261