#!/usr/bin/python
#why doesn't this run both threads simultaneously?
#Thanks for any help.
#Chuckk
import threading
import time
def printesc(thrd):
for i in range(10):
time.sleep(1)
print thrd, i
def master():
thd1 = threading.Thread(target=printesc, args=(1,))
thd2 = threading.Thread(target=printesc, args=(2,))
thd1.run()
thd2.run()
master() 5 801
On May 20, 8:19*am, "Chuckk Hubbard" <badmuthahubb...@gmail.com>
wrote:
#!/usr/bin/python
#why doesn't this run both threads simultaneously?
#Thanks for any help.
#Chuckk
import threading
import time
def printesc(thrd):
* * for i in range(10):
* * * * time.sleep(1)
* * * * print thrd, i
def master():
* * thd1 = threading.Thread(target=printesc, args=(1,))
* * thd2 = threading.Thread(target=printesc, args=(2,))
* * thd1.run()
* * thd2.run()
master()
You meant 'thd1.start( )' and 'thd2.start( )'.
Chuckk Hubbard wrote:
#!/usr/bin/python
#why doesn't this run both threads simultaneously?
#Thanks for any help.
#Chuckk
Because you should call thread.start().
Diez
En Tue, 20 May 2008 10:28:51 -0300, castironpi <ca********@gmail.com>
escribió:
You meant 'thd1.start( )' and 'thd2.start( )'.
Wow! A message with a high S/N ratio coming from you!
And it's not the first I've seen - whatever pills you're taking, they're
good for you...
--
Gabriel Genellina
On Tue, May 20, 2008 at 8:24 PM, Gabriel Genellina
<ga*******@yahoo.com.arwrote:
En Tue, 20 May 2008 10:28:51 -0300, castironpi <ca********@gmail.com>
escribió:
>You meant 'thd1.start( )' and 'thd2.start( )'.
Wow! A message with a high S/N ratio coming from you!
And it's not the first I've seen - whatever pills you're taking, they're
good for you...
This is why I shouldn't be so eager adding people to the killfile.
--
Eduardo de Oliveira Padoan http://www.advogato.org/person/eopadoan/ http://twitter.com/edcrypt
Bookmarks: http://del.icio.us/edcrypt
On Tue, May 20, 2008 at 4:28 PM, castironpi <ca********@gmail.comwrote:
On May 20, 8:19 am, "Chuckk Hubbard" <badmuthahubb...@gmail.com>
wrote:
>#!/usr/bin/python
#why doesn't this run both threads simultaneously? #Thanks for any help. #Chuckk
import threading import time
def printesc(thrd): for i in range(10): time.sleep(1) print thrd, i
def master(): thd1 = threading.Thread(target=printesc, args=(1,)) thd2 = threading.Thread(target=printesc, args=(2,)) thd1.run() thd2.run()
master()
You meant 'thd1.start( )' and 'thd2.start( )'.
So I did. I was mixing what I read of thread and threading. I'll
never wander beyond my Python module reference html folder again.
Thanks for your help.
-Chuckk
-- http://www.badmuthahubbard.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Anthony Baxter |
last post by:
On behalf of the Python development team and the Python community, I'm
happy to announce the release of Python 2.3.1 (final).
Python 2.3.1 is a pure bug fix release of Python 2.3, released in...
|
by: kanzen |
last post by:
I keep telling my friends that Python rocks. Now it's time to put my
money where my mouth is. I'm about to start writing a server for a
phone based game. It needs to handle simlpe requests from...
|
by: David Harrison |
last post by:
I am working on an application on Mac OS X that calls out
to python via PyImport_ImportModule(). I find that if
the imported module creates and starts a python thread,
the thread seems to be...
|
by: Qiangning Hong |
last post by:
I decide to seperate my data collection routine from my data analysis
and storage program to a seperate process, so I try to use the new
subprocess model in Python 2.4.
The main program spawns...
|
by: Yannick |
last post by:
Hi,
I would like to program a small game in Python, kind of like robocode
(http://robocode.sourceforge.net/).
Problem is that I would have to share the CPU between all the robots,
and thus...
|
by: momobear |
last post by:
I feel really puzzled about fellowing code, please help me finger out
what problem here.
import threading
class workingthread(threading.Thread):
def __init__(self):
self.quitEvent =...
|
by: Kurt B. Kaiser |
last post by:
Patch / Bug Summary
___________________
Patches : 385 open (+21) / 3790 closed (+21) / 4175 total (+42)
Bugs : 1029 open (+43) / 6744 closed (+43) / 7773 total (+86)
RFE : 262 open...
|
by: Ling |
last post by:
I am using boost.python to wrap C++ function which includes
directmusic libraries to simply play the midi, but lots of linkage
errors "error LNK2001: unresolved external symbol". I wonder if it is...
|
by: Matthew Wilson |
last post by:
In this code, I tried to kill my thread object by setting a variable on it
to False.
Inside the run method of my thread object, it checks a different
variable.
I've already rewritten this...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |