This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

davmac
davmac presents ...

2010/10/14

threadact

This is an example (with some re-usable classes) of safely implementing actor logic in "sequences" - threads which regularly give up control via method call.

A ThreadActor can have one or more sequences, and in the act() method it processes each sequence. The sequence does whatever it wants to do and then calls waitForNextSequence() to relinquish control to the next sequence (or actor).

The example uploaded here shows an actor with two sequences: one which moves it, and another which rotates it.

3605 views / 13 in the last 7 days

Tags: with-source scratch threads

open in greenfoot
Your browser does not support the canvas tag.
I don't understand this code. Where is the waitForNextSequence() implemented?
davmacdavmac

2012/5/8

In the Sequence class.
I'm sorry for being so ignorant, but I don't see anything like this when I google for java sequence. Also, I thought a google for waitForNextSequence would turn up a hit, too, but it doesn't. Can you post a link to an API definition online? Thanks.
D'oh! I just found the Sequence class in the code you provided. Nevermind me...

Want to leave a comment? You must first log in.

Who likes this?

No votes yet.