本文整理汇总了Python中java.lang.Thread方法的典型用法代码示例。如果您正苦于以下问题:Python lang.Thread方法的具体用法?Python lang.Thread怎么用?Python lang.Thread使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang
的用法示例。
在下文中一共展示了lang.Thread方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test931
# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Thread [as 别名]
def test931():
'''exec and eval are not thread safe'''
from java.lang import Thread
class TestThread(Thread):
def run(self):
for i in range(30):
exec("x=2+2")
testers = []
for i in range(10):
testers.append(TestThread())
for tester in testers:
tester.start()
for tester in testers:
tester.join()
示例2: newThread
# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Thread [as 别名]
def newThread(self, runnable):
t = Thread(runnable)
t.daemon = True
t.name = self.label % (self.thread_count.getAndIncrement())
return t
示例3: startAPI
# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Thread [as 别名]
def startAPI(self, button):
if self.apistatus == 0:
try:
print 'Calling: ' + self.pythonfile + ' ' + self.apifile + ' -s -H ' + self._jTextFieldIPListen.getText() + ' -p ' + self._jTextFieldPortListen.getText() + '\n'
sqlmapdir = ''
if re.search('^[a-zA-Z]\:', self.apifile) is not None:
sqlmapdir = self.apifile.rsplit('\\', 1)[0]
else:
sqlmapdir = self.apifile.rsplit('/', 1)[0]
javaexec = getattr(Runtime.getRuntime(), "exec")
cmd = [self.pythonfile, self.apifile, "-s", "-H", self._jTextFieldIPListen.getText(), "-p", self._jTextFieldPortListen.getText()]
self.apiprocess = javaexec(cmd, None, File(sqlmapdir))
self.errorGobbler = Thread(StreamGobbler(self.apiprocess.getErrorStream(), System.err))
self.outputGobbler = Thread(StreamGobbler(self.apiprocess.getInputStream(), System.out))
self.errorGobbler.start()
self.outputGobbler.start()
# Final validation the API is running
try:
time.sleep(5)
req = urllib2.Request('http://' + self._jTextFieldIPListen.getText() + ':' + self._jTextFieldPortListen.getText() + '/scan/0/status')
req.add_header('Content-Type', 'application/json')
resp = json.load(urllib2.urlopen(req, timeout=10))
if resp['message'] == "Invalid task ID":
self._jLabelScanAPI.setText(self._jTextFieldIPListen.getText() + ':' + self._jTextFieldPortListen.getText())
self._jLabelScanAPI.setForeground(Color.GREEN)
self._jTextFieldScanIPListen.setText(self._jTextFieldIPListen.getText())
self._jTextFieldScanPortListen.setText(self._jTextFieldPortListen.getText())
self._jLabelAPIStatus.setText('SQLMap API IS CURRENTLY RUNNING!')
self._jLabelAPIStatus.setForeground(Color.GREEN)
self.apistatus = 1
print 'SQLMap API started.\n'
except:
self.apiprocess.destroy()
self.errorGobbler.join()
self.outputGobbler.join()
print 'Failed to start the SQLMap API\n'
except:
print 'Failed to start the SQLMap API\n'
else:
print 'The SQLMap API process has already been started\n'
示例4: refresh
# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Thread [as 别名]
def refresh(self):
thread = Thread(RefreshRunnable(self))
thread.start()