You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#!/usr/bin/env python
# coding=utf-8
from threading import Thread
from threading import _Event
class TestThread(Thread):
global e
def __init__(self):
Thread.__init__(self)
def run(self):
if(e.isSet()):
e.clear()
# 线程等待,如果信号为真,清理信号,并且等待
# 等待的时候,另外一个线程,直接接收这个假的信号
# 当这个假的信号执行下面的else语句后,信号为真
# 之前wait的信号就会继续往下执行了
e.wait()
print self.getName()
else:
e.set()
print self.getName()
def main():
threads = []
for i in range(4):
threads.append(TestThread())
threads[i].setDaemon(True)
threads[i].start()
for x in range(4):
threads[x].join()
if __name__ == '__main__':
e = _Event()
e.set()
main()
0x03 一天总结
多线程之子线程与主线程的关系
setDaemon()
多线程之线程锁
Lock().acquire()
Lock().release()
多线程之_Event事件
set()
wait()
clear()
isSet()
The text was updated successfully, but these errors were encountered:
0x01 Wooyun
session
验证,JSP
、JSPX
、替换统统失败,可以利用weblogic
部署,假如默认的console
也被删的话,自行添加一个域,利用这个域本地配置war
包来读取内网数据库SQL
注入Java
反序列化命令执行member_id
发送,就可以登录其他用户Burpsuite
爆破0x02 爬虫实战一
setDaemon()
设置True
,主线程结束的时候,子线程也会结束,主线程其实就是程序的主运行流程,子线程就是程序中设置的一个个单独工作的线程,主线程一定是程序最先运行,负责拉起子线程干活,所以最后就需要join()
,来阻塞线程,强制程序等待所有子线程全部完成才继续执行后面的主线程程序Lock
线程锁,多个线程之间同时操作同一个资源(也就是全局变量)的时候,哪个线程先操作,哪个线程就先锁定这个资源,直到这个线程操作结束打开锁之后,其他线程才可以操作,也称为线程安全,和join()
不同的是,线程锁只是锁定线程内部某个需要处理的资源(比如某个变量),而join()
是对整个线程作出限制l = Lock()
(from threading import Lock
)l.acquire()
上锁l.release()
解锁发布_Event
事件对象,是线程之间最简单的通信机制之一,它是由线程设置的信号标志,如果标志为真,则其他线程等待直到信号解除set()
设置信号为真,isSet()
可以判断其内部信号标志的状态clear()
清楚信号,即设为假,isSet()
返回假wait()
只有在内部信号为真的时候才会很快的执行并完成返回,当内部信号为假时,则wait
方法一直等待其为真时才返回,也就是说wait
只有接受到信号为真,才会往下执行,否则不这个线程就被挂起等待信号为真0x03 一天总结
setDaemon()
Lock().acquire()
Lock().release()
_Event
事件set()
wait()
clear()
isSet()
The text was updated successfully, but these errors were encountered: