Quickies

[categories] [index] [all (527)] [latest]

Python
  1. #!/usr/bin/python
    
    import thread
    import time
    
    def my_function():
        while 1:
            print "thread 2"
            time.sleep(0.6)
    
    print "-- will detach new thread"
    thread.start_new_thread(my_function, ())
    print "-- did detach new thread"
    
    while 1:
        print "thread 1"
        time.sleep(1)