The Artima Developer Community
Sponsored Link

Python Buzz Forum
PushToTest - Free open-source software test automation solutions - Writing Threaded Applications...

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ed Taekema

Posts: 52
Nickname: etaekema
Registered: Jul, 2004

Ed Taekema is a wandering Jython enthusiast
PushToTest - Free open-source software test automation solutions - Writing Threaded Applications... Posted: Apr 26, 2005 7:35 PM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Ed Taekema.
Original Post: PushToTest - Free open-source software test automation solutions - Writing Threaded Applications...
Feed Title: All things Jythonic
Feed URL: http://www.pycs.net/users/0000177/categories/jython/rss.xml
Feed Description: Blogging Jython...
Latest Python Buzz Posts
Latest Python Buzz Posts by Ed Taekema
Latest Posts From All things Jythonic

Advertisement
Here is a quick tutorial on writing thread safe jython scripts. The author implements thread safe examples using both Python and Java methods. Here is the article's conclusion

Based on my experience writing threaded applications in Jython, using Java Threads and the Runnable interface is the best practice. The following Jython script implements the best practice for building threaded applications in Jython:

from java.lang import Thread, Runnable
import synchronize

  class myclass( Runnable ):
    def __init__( self, myparam ):
      self.storeit = myparam

    def setMyparam( self, myparam ):
      self.storeit = myparam
    setMyparam=synchronize.make_synchronized( setMyparam )

    def printMyparam( self ):
      print "myclass: myparam =",self.storeit
    printMyparam=synchronize.make_synchronized( printMyparam )

    def run( self ):
      for self.i in range(5):
        self.printMyparam()

  count = 2

  a = myclass()
  a.setMyparam( "frank" )

  t = Thread( a, "MyThread %d" % count )
  t.start()

Read: PushToTest - Free open-source software test automation solutions - Writing Threaded Applications...

Topic: Python splitting up a sequence Previous Topic   Next Topic Topic: Google Desktop Search Plug-in in Python?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use