[Python module] threading
threading — Higher-level threading interface
This module constructs higher-level threading interfaces on top of the lower level _thread module. See also the queue module.
The dummy_threading module is provided for situations where threading cannot be used because _thread is missing.
Õâ¸öÄ£¿éÊǹ¹½¨Ôڵײã_threadÄ£¿éÉϵġ£
dummy_threadingÄ£¿éÌṩÁË¿Éthreading£¨ÓÉÓÚ_threadȱʧ£©Ä£¿é²»ÄÜʹÓõÄÇé¿ö¡£
Note
While they are not listed below, the camelCase names used for some methods and functions in this module in the Python 2.x series are still supported by this module.
This module defines the following functions and objects:
threading.active_count() Return the number of Thread objects currently alive. The returned count is equal to the length of the list returned by enumerate().
threading.Condition() A factory function that returns a new condition variable object. A condition variable allows one or more threads to wait until they are notified by another thread.threading.current_thread() Return the current Thread object, corresponding to the caller’s thread of control. If the caller’s thread of control was not created through the threading module, a dummy thread object with limited functionality is returned.threading.enumerate() Return a list of all Thread objects currently alive. The list includes daemonic threads, dummy thread objects created by current_thread(), and the main thread. It excludes terminated threads and threads that have not yet been started.threading.Event() A factory function that returns a new event object. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true.class threading.local
A class that represents thread-local data. Thread-local data are data whose values are thread specific. To manage thread-local data, just create an instance of local (or a subclass) and store attributes on it:
mydata = threadi
Ïà¹ØÎĵµ£º
Ò»¡¢pythonÊÇʲô£¿
Æäʵ£¬python¾ÍÊÇÒ»Ãűà³ÌÓïÑÔ£¬¾ÍÏñjavaÒ»Ñù¡£±¾À´ÊÇÔÚµçÄÔÉϵ쬵«ÊÇËæ×ÅÊÖ»úµÄÁ÷ÐУ¬python±»ÒÆÖ²µ½ÁËÊÖ»úÉÏ£¬Í¬Ê±Ò²±»ÃüÃûΪpyS60¡£
¶þ¡¢pyÈí¼þµÄ¹¹Ôì
ËùÓеÄpyÈí¼þ¶¼Òª°üÀ¨ÈçÏÂÎļþ£º.app--1.65k£».rsc--337b£».aif¡£ÕâÈý¸öÎļþÔÚËùÓÐpyÈí¼þÖж¼ÊÇÏàͬµÄ£¬Î¨Ò»µÄÇø±ð¾ÍÊÇÈí¼þµÄuid²»Í¬¡£ÕâЩÎļ ......
#!/usr/bin/env python2
import pcap
import sys
import string
import time
import socket
import struct
protocols={socket.IPPROTO_TCP:'tcp',
socket.IPPROTO_UDP:'udp',
socket ......
PythonµÄ´´Ê¼ÈËΪGuido van
Rossum¡£1989ÄêÊ¥µ®½ÚÆÚ¼ä£¬ÔÚ°¢Ä·Ë¹Ìص¤£¬GuidoΪÁË´ò·¢Ê¥µ®½ÚµÄÎÞȤ£¬¾öÐÄ¿ª·¢Ò»¸öеĽű¾½âÊͳÌÐò£¬×öΪ ABC
ÓïÑÔµÄÒ»Öּ̳С£Ö®ËùÒÔÑ¡ÖÐ Python£¨´óòþÉßµÄÒâ˼£©×÷Ϊ³ÌÐòµÄÃû×Ö£¬ÊÇÒòΪËûÊÇÒ»¸öMonty PythonµÄ·ÉÐÐÂíÏ·Íŵİ®ºÃÕß¡£
ABCÊÇÓÉGuido²Î¼ÓÉè¼ÆµÄÒ»ÖÖ½ÌѧÓïÑÔ¡£¾ÍGuido±¾ÈË¿´ ......
Python ÉçÇøÓоäË×Ó“Python ×Ô¼º´ø×Åµç³Ø¡£” ±ð×Ô¼ºÐ´¼ÆÊ±¿ò¼Ü¡£Python 2.3ÒÔºó ¡¢¾ß±¸Ò»¸ö½Ð×ö timeit µÄÍêÃÀ¼ÆÊ±¹¤¾ß¡£DiveIntoÖеÄÀý×Ó
>>> import timeit
>>> t = timeit.Timer("soundex.soundex('Pilgrim')",
... "import soundex")
>>> t.timeit() ......
1. µÚÒ»Õ¡¡Python¿ìËÙÈëÃÅ
±¾ÕÂÊÇPythonµÄ¿ìËÙÈëÃÅ£¬ÔÚÕâÒ»Õ²¢²»Éæ¼°pythonµÄÌØÊâ¹æÔòºÍϸ½Ú£¬Ä¿±êÊÇͨ¹ýʾÀýʹÄã¿ìËÙÁ˽âPythonÓïÑÔµÄÌØµã¡£±¾Õ¼òÒª½éÉÜÁ˱äÁ¿,±í´ïʽ,¿ØÖÆÁ÷,º¯ÊýÒÔ¼°ÊäÈë/Êä³öµÄ»ù±¾¸ÅÄî,ÔÚÕâÒ»Õ²»Éæ¼°PythonÓïÑԵĸ߼¶ÌØÐÔ¡£¾¡¹ÜÈç´Ë£¬ÓоÑéµÄ³ÌÐòÔ±»¹ÊÇÄܹ»Í¨¹ýÔĶÁ±¾ÕµIJÄÁÏ´´½¨¸ß¼¶³ÌÐò¡£ÎÒÃÇ ......