D
D
Dima_E2020-01-04 18:39:53
Python
Dima_E, 2020-01-04 18:39:53

How to implement multithreading in the program?

When compiling a multi-threaded program on Windows, I ran into a problem that if __name__ == '__main__': does not work and when threads start, they start restarting themselves, how to fix it?
It seems that I read that there is such a problem with Windows, but I don’t remember where.
The problem is the current in the running program, if you run it from the command line, then everything works as it should.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikita Panuhin, 2020-01-04
@Dima_E

If the file with if __name__ == "__main__":is started from some other file, then the if will not work.
Accordingly, if you need to use the file in a program with multithreading, you need to remove this if .

A
Alexander, 2020-01-04
Spokoyny @cyshka0

remove the if if you are using a program with multithreading. And that won't work

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question