Python Forum
running two functions by threading
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
running two functions by threading
#1
Hi
I'm trying to play two function at same time but one of this two function works only one time



import threading, time, sys





class counter :
    
    def num(self):
        for i in range (60):
            print(i)
            time.sleep(.5)

    def handler(self):
        print(' Processing .. ')
        time.sleep(3)





th1 = threading.Thread(target = counter().num).start()
th2 = threading.Thread(target = counter().handler).start()
Reply


Messages In This Thread
running two functions by threading - by Fathy - Feb-09-2018, 01:42 PM
RE: running two functions by threading - by ka06059 - Feb-10-2018, 07:06 AM
RE: running two functions by threading - by Fathy - Feb-10-2018, 07:30 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Concurrent futures threading running at same speed as non-threading billykid999 13 1,902 May-03-2023, 08:22 AM
Last Post: billykid999
  Tutorials on sockets, threading and multi-threading? muzikman 2 2,144 Oct-01-2021, 08:32 PM
Last Post: muzikman
  Running scripts and location of saved interpreted user-defined classes and functions leodavinci1990 3 2,556 Aug-25-2020, 03:43 AM
Last Post: micseydel
  Multiproccessing ValueError: Pool not running when running parallel functions Gilush 1 3,349 Jun-06-2020, 12:49 AM
Last Post: Gilush
  code keeps running if i use from threading import timer? birddseedd 3 2,628 Jan-25-2019, 05:00 AM
Last Post: stullis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020