[Tutor] simple threads program

Kalle Svensson kalle@lysator.liu.se
Fri Jul 18 06:57:01 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[Andreas Zwinkau]
> I didn't really read your script, i must admit, but here is the
> shortest usage of threading i can think of:
> 
> import thread
...

You shouldn't really use the thread module unless you have a good
reason to.  Use threading instead.

  import threading

  class Thread1(threading.Thread):
      def run(self):
  	# do thread 1 stuff.

  class Thread2(threading.Thread):
      def run(self):
  	# do thread 2 stuff.

  t1 = Thread1()
  t2 = Thread2()
  t1.start()
  t2.start()

Peace,
  Kalle
- -- 
Kalle Svensson, http://www.juckapan.org/~kalle/
Student, root and saint in the Church of Emacs.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE/F9I4dNeA1787sd0RAh6hAJ9KJckSj+nB7yRznGRN61VT+OW/pgCgztBn
XbKgyylWBrm4+71e9US4xQw=
=eAWJ
-----END PGP SIGNATURE-----