user9870883
user9870883

Reputation:

How can I import thread package in Python 3?

I want to import thread package in Python 3.6. But this error is occurred:

import thread
ModuleNotFoundError: No module named 'thread'

Upvotes: 7

Views: 15148

Answers (3)

Foxman
Foxman

Reputation: 23

Use the module _thread.

import _thread

Upvotes: 1

mahdi_asdzd
mahdi_asdzd

Reputation: 11

import threading 

def main():
...

if __name__ =="__main__":

    t1 = threading.Thread(target=main, args=())
    t2 = threading.Thread(target=main, args=())
 
    t1.start()
    t2.start()
 
    t1.join()
    t2.join()

Upvotes: 1

philoez98
philoez98

Reputation: 493

Change it to import threading.

Upvotes: 10

Related Questions