intro-tut1x

hopeacceptableSoftware and s/w Development

Oct 28, 2013 (3 years and 8 months ago)

60 views

Multicore Programming

Tutorial
1

CS
0368
-
3469

Spring
2010


2

Administrative

Staff


Prof. Nir
Shavit
,
shanir@post.tau.ac.il


T.A.
-

Guy Korland,
guykorland@post.tau.ac.il


3

Administrative

Info


Web:
http://www.cs.tau.ac.il/~multi/


RSS:
http://www.cs.tau.ac.il/~multi/rss.php


Forum



Will be published

4

Administrative

The Textbook


The Art of Multiprocessor


Programming,


Herlihy and Shavit,

5

Requirements


6
assignments (
20
%)


4
% each (
5
out of
6
)


Final exam (
80
%)

6

Assignments


http://www.cs.tau.ac.il/~multi/index.php?p=administ


http://www.cs.tau.ac.il/~multi/index.php?p=technical



7

8

9

Java
-

links


Download
JDK
6.0
:
http://java.sun.com/javase/downloads/widget/jdk
6
.jsp


JDoc
:
http://java.sun.com/javase/
6
/docs/api/


IDE
:
http://www.eclipse.org/downloads/


ANT:
http://ant.apache.org/bindownload.cgi






10

Java Class Example

package

example;

import

java.awt.Point;

public class

Rectangle {




private

int

width =
0
;


private

int

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;


}


public

void

setWidth(int width)


{


this
.width = width;



}

}

data members

constructors

a method

11

Running Java Programs

package

mp
;
// file
mp
/HelloWorld.java

public class

HelloWorld

{

public static

void

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!”


12

Java Threads


java.lang.Thread


class

MyThread
extends

Thread{


@Override


public

void

run(){





}

}


public

static void

main(String args[]){


MyThread thread =
new

MyThread();


thread.start();


try

{



thread.join();


}


catch

(InterruptedException e) { };

}

13

Java concurrent


Concurrent:
http://
java.sun.com/j
2
se/
6
/docs/api/java/util/concurrent/package
-
tree.html


Locks:


http://java.sun.com/j
2
se/
6
/docs/api/java/util/concurrent/locks/package
-
summary.html



14

Java
-

Overview


final, static, private,



Exception, try
-
catch & finally


Types
-

References and Primitives


Wrappers (int vs Integer)


Inheritance & Interfaces




15

Ant
-

Overview

<
project

name
="Ex
0
"
default
="run"
basedir
="."
<



<
property

name
="src"
location
="src"/>



<
target

name
="compile"
depends
="init">



<
javac

srcdir
="${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
>


16