-3

I have this code here:

t = theading.Thread(target = arping)
t.start()

Can someone please explain to me what does threading.Thread do? I know it may seem like a stupid question, but I don't understand this line.

dor132
  • 183
  • 1
  • 1
  • 8

2 Answers2

2

That line creates an instance of the threading.Thread class. See here for more details.

tbrisker
  • 15,518
  • 1
  • 16
  • 17
0

The line t = threading.Thread(target = arping) creates a threading.Thread class with a call to arping by the class run() method.

Basically, that means that the script will run the arping function in a new and separate thread.

The second line t.start() actually starts the thread, which in turns calls the run() method which will run the arping callable object.

About the concept of threads, you can read more about it here.

As tbrisker said, you can have more info on the python docs.

Community
  • 1
  • 1
achedeuzot
  • 4,164
  • 4
  • 41
  • 56