當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。