Home
>>     < >




In-class notes for 01/11/2018

CS 284 (MCA), Interim 2018

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().
    Example threads/Bounce.java

  • Double buffering; drawing on Images. Example threads/Bounce2.java

  • Concept of multithreaded application. Critical section, race conditions, blocking, deadlock.

  • Java synchronized keyword: synchronized instance or class method; synchronized (obj-or-array) statement

  • Each Java object has its own monitor, which provides mutual exclusion for synchronized methods or code segments

    Java monitors: synchronized, wait(), notify(). Threads examples threads/Bounce.java, threads/Bounce2.java

  • Subclassing Thread vs implementing Runnable

    • Needing other methods of Thread besides run()


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.

  1. 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.

    1. Open a terminal window, and enter

      ls ~/git
      
      to see if a directory ~/git already exists. If the ls command causes an error, create ~/git using
      mkdir ~/git
      

    2. 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.

    3. 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
      

    For the steps below, we will refer to this working directory as ~/git/username-react. If you're using a different path, adjust the instructions below accordingly.
  2. Now, cd to the parent directory of your react-install directory. (You can check this by entering ls -- look for react-install as one of the items listed.) In that parent directory, move your react-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 ~/git/username-react 
    ls
    ls react-install
    
    The first ls should show the react-install directory you just copied, and the second ls should list your application directory (containing App.js and other files in your React Native installation). From now on, use
     
    ~/git/username-react/react-install
    
    to access your React Native installation
    .

  3. Now, make and push a commit of your React Native work. Note: your application directory should automatically have a .gitignore file that prevents committing 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




< >