"Dominik Kaspar" <> wrote in message
news: om...
> maybe my question was badly formulated. i give it a new try:
> why does the following program give the output "0 0" and not "1 0"?
> why does it loop forever? and how could that problem be fixed?
As written, you have a local varaible running in method run that gets set
and never changes. The class variable you're looking for is Server.running,
like this:
import time, threading
class Server(threading.Thread):
running = 0
def run(self):
Server.running = 1
while Server.running:
print "do something here..."
time.sleep(5)
def stop(self):
Server.running = 0
server = Server()
server.start()
print server.running # should print "1"
server.stop()
--
Emile van Sebille