160 likes | 310 Views
Multicore Programming. Tutorial 1 CS 0368-3469 Spring 2010. Administrative. Staff Prof. Nir Shavit , shanir@post.tau.ac.il T.A. - Guy Korland, guykorland@post.tau.ac.il. Administrative. Info Web: http://www.cs.tau.ac.il/~multi/ RSS: http://www.cs.tau.ac.il/~multi/rss.php
E N D
Multicore Programming Tutorial 1 CS 0368-3469Spring 2010
Administrative Staff • Prof. Nir Shavit, shanir@post.tau.ac.il • T.A. - Guy Korland, guykorland@post.tau.ac.il
Administrative Info • Web: http://www.cs.tau.ac.il/~multi/ • RSS: http://www.cs.tau.ac.il/~multi/rss.php • Forum– Will be published
Administrative The Textbook The Art of Multiprocessor Programming, Herlihy and Shavit,
Requirements • 6 assignments (20%) • 4% each (5 out of 6) • Final exam (80%)
Assignments • http://www.cs.tau.ac.il/~multi/index.php?p=administ • http://www.cs.tau.ac.il/~multi/index.php?p=technical
Java - links • Download JDK6.0: http://java.sun.com/javase/downloads/widget/jdk6.jsp • JDoc: http://java.sun.com/javase/6/docs/api/ • IDE: http://www.eclipse.org/downloads/ • ANT: http://ant.apache.org/bindownload.cgi
Java Class Example package example; import java.awt.Point; public class Rectangle { privateint width = 0; privateint height = 0; private Point origin; public Rectangle() { origin = new Point(0, 0); } public Rectangle(int w, int h) { this(new Point(0, 0), w, h); } public Rectangle(Point p, int w, int h) { origin = p; width = w; height = h; } publicvoid setWidth(int width) { this.width = width; } } data members constructors a method
Running Java Programs packagemp; // file mp/HelloWorld.java public classHelloWorld { public staticvoid main(String[] args) { System.out.println(“Hello World !”); } } > javac HelloWorld.java The compilation phase: This command will produce the java bytecode file HelloWord.class > java –cp . HelloWorld The execution phase (on the JVM): This command will produce the output “Hello World!”
Java Threads • java.lang.Thread class MyThread extends Thread{ @Override publicvoid run(){ … } } publicstatic void main(String args[]){ MyThread thread = new MyThread(); thread.start(); try { thread.join(); } catch (InterruptedException e) { }; }
Java concurrent • Concurrent: http://java.sun.com/j2se/6/docs/api/java/util/concurrent/package-tree.html • Locks: http://java.sun.com/j2se/6/docs/api/java/util/concurrent/locks/package-summary.html
Java - Overview • final, static, private, … • Exception, try-catch & finally • Types - References and Primitives • Wrappers (int vs Integer) • Inheritance & Interfaces
Ant - Overview <projectname="Ex0" default="run" basedir="."< <propertyname="src" location="src"/> <targetname="compile" depends="init"> <javacsrcdir="${src}" destdir="${build}"/> </target> …
Ant – Overview cont. … <target name="run" depends="compile" description="run the program"> <java classname="mpp.Example" classpath="${build}" fork="true"/> </target> </project>