-1

I have a very simple thread in python:

threading.Thread(target=self.clock).start()

All I want to do is be able to delete the current one and make a new one (that will be set to 0 seconds), so it can start counting again, but no matter what I try I cannot stop the original thread from counting.

Georgy
  • 12,464
  • 7
  • 65
  • 73
AuctortiA
  • 146
  • 7
  • I’m just looking for a very simple way I.e one command, also my I’m not using a thread class – AuctortiA Jun 25 '19 at 12:17
  • There is no simple way. A thread runs until the `target` function returns. And you *are* using a thread class: `threading.Thread`. – mkrieger1 Jun 25 '19 at 12:18
  • my own thread class* – AuctortiA Jun 25 '19 at 12:19
  • This question was already asked. Check this: - [Kill a thread](https://stackoverflow.com/questions/323972/is-there-any-way-to-kill-a-thread) You set a value which the thread will check. You can also use a flag to stop it. – Bando Jun 25 '19 at 12:23
  • You say it's "very simple," but the one line of code that _starts_ the thread doesn't prove anything. It's what the thread _does_ that defines whether it is simple or sophisticated. Any time you have a question about a thread, the code that the thread executes and the code executed by other threads with which it interacts usually is _much_ more pertinent than the code that launches it. – Solomon Slow Jun 25 '19 at 13:57
  • unless I want to find out how to delete it... in which case the code it executed is irrelevant... – AuctortiA Jun 25 '19 at 13:58

1 Answers1

-1

Unlike the processes that can be terminated, the thread will run until the function returns.

Kamuish
  • 118
  • 6