当前位置: 首页>>代码示例>>Python>>正文


Python lang.Thread方法代码示例

本文整理汇总了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() 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:22,代码来源:bugs101.py

示例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 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:7,代码来源:_socket.py

示例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' 
开发者ID:codewatchorg,项目名称:sqlipy,代码行数:51,代码来源:SQLiPy.py

示例4: refresh

# 需要导入模块: from java import lang [as 别名]
# 或者: from java.lang import Thread [as 别名]
def refresh(self):
        thread = Thread(RefreshRunnable(self))
        thread.start() 
开发者ID:penafieljlm,项目名称:burp-tracer,代码行数:5,代码来源:tracer.py


注:本文中的java.lang.Thread方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。