Computer Science 225
Advanced Programming
Spring 2021, Siena College
Lecture 17: More Threads; Handling Keyboard Events
Date: Monday, April 26, 2021
Agenda
- Announcements
- Office hours update for this week
- Tuesday 9-10:30 as usual, virtual only this week
- Wednesday (College holiday) by appointment, in person or
virtual (plus review times as mentioned below)
- Thursday, cancelled due to a conflicting medical appointment
- Friday 1:30-2:30, as usual, in person or virtual
- Lab 8: Animation (in Canvas and GitHub)
- not due until May 4 or 5 depending on your lab section
- if you have finished the required functionality (as many
have) and decide to go back to add some bonus functionality, be
sure to let me know so I notice it
- the threading and animation aspect of this lab is not fair
game for the exam this week, but the code refactoring to add a
common base class is
- Problem Set 5
- some look to be done, others look to be unstarted
- due tomorrow
- Final Project
- groups should now be formed and repositories created
- Proposals not due until Friday, but you are encouraged to
get them in so I can check them sooner
- Exam 2
- see the information/study guide shared document
- Two review times available on Wednesday
- 10:30-11:30 and 1:30-2:30
- I'll open the class Zoom link
- if people are interested in joining in person on the day
off, we can probably use our regular classroom and if not will
find a place
- I can record if anyone would like
- In-class exercise (5 points), create a Google document in your
shared CSIS 225 folder for your response.
- Build a table that lists all of the possible interleavings of
the instructions in the notes where Thread A and Thread B
concurrently execute an increment and a decrement of the same
variable counter.
- Suppose the counter variable starts at 0 before any of
the statements are executed. Add a column to your table that
gives the value of counter after the statements have been
executed.
- Highlight the rows so that ones for which counter will
have the correct final value (that is, the same as it was when we
started) in green, and ones that give an incorrect answer in
red.
- Handling keyboard events
- repaint frequency
- Bouncing
Terminology
Examples
- ArrowBall: handling keyboard events, in this case arrow keys, in a graphics program
- SnowScene (same as before, will modify in class)
- BallTosser: animation with bouncing off the walls and gravity.