In-class notes for 01/11/2018
CS 284 (MCA), Interim 2018
Lab assignment due at "midnight"
HW2 under construction
This session: Lab 7: Threads: Bouncing Ball
Submitted questions on assignments and technology
Submitted questions on Java reading
Threads lab
Drawing in a Java applet; methods
paint(), repaint()
.
Examplethreads/Bounce.java
Double buffering; drawing on
Images
. Examplethreads/Bounce2.java
Concept of multithreaded application. Critical section, race conditions, blocking, deadlock.
Java
synchronized
keyword: synchronized instance or class method; synchronized (obj-or-array) statementEach Java object has its own monitor, which provides mutual exclusion for
synchronized
methods or code segmentsJava monitors:
synchronized, wait(), notify()
. Threads examplesthreads/Bounce.java
,threads/Bounce2.java
Subclassing
Thread
vs implementingRunnable
Needing other methods of
Thread
besidesrun()
Adding react-install to your git repository
Here are instructions for adding react-install
to your
stogit repository for the course. This makes it possible to
record working versions of your App.js
or other
app files so you can return to them later (e.g., for debugging),
and also to submit ReactNative work to stogit for homework,
etc.
These instructions were developed on Mac/Linux. We will add Windows variants as comments.
First, make sure you have a working directory for your stogit repository
mca-i18/username
on your computer. This working directory will contain your React Native installation, so we suggest you create a new working directory for this purpose, as follows.Open a terminal window, and enter
ls ~/git
to see if a directory~/git
already exists. If thels
command causes an error, create~/git
usingmkdir ~/git
If you've never used git on this computer before, then execute these commands
git config --global user.name "Your Name" git config --global user.email username@stolaf.edu git config --global core.editor "emacs" # or some other editor command
Also create an SSH key (unless there already is one in~/.ssh/id_rsa.pub
)ssh-keygen
(enter newlines in response to all prompts) and enter that key in stogit via the stogit browser interface.Make a clone of your stogit repository for homework and labs.
cd ~/git git clone git@stogit.cs.stolaf.edu:mca-i18/username.git username-react
~/git/username-react
. If you're using a different path, adjust the instructions below accordingly.Now,
cd
to the parent directory of yourreact-install
directory. (You can check this by entering ls -- look forreact-install
as one of the items listed.) In that parent directory, move yourreact-native
installation to your git working directory.Mac or Linux:
mv react-native
~/git/username-react
Windows: (Untested)
move react-native C:\users\yourWindowsUser\git\username-react
To check this step,
cd
The first~/git/username-react
ls ls react-installls
should show thereact-install
directory you just copied, and the secondls
should list your application directory (containingApp.js
and other files in your React Native installation). From now on, use~/git/username-react
/react-installNow, make and push a commit of your React Native work. Note: your application directory should automatically have a
.gitignore
file that preventscommit
ting library files that are part of React.cd
~/git/username-react
git add react-install git commit -m "Add react-install to repository" git pull origin master git push origin master
React file hierarchy and navigation
< >