| Quiz |
Posted |
Given in class |
| | 20 | Feb |
25 | Feb |
public class Point {
public Point(int x, int y) {
this.x = x; this.y = y;
}
public double getDist() {
return Math.sqrt(x*x + y*y);
}
}
Answers can be written below or on back
- Is the above class thread-safe? If so explain why; if not,
rewrite it to make it thread-safe.
- Write a program in Java that can deadlock.
- Extra credi: Given a Set s, write a class
SetLock patterned after DoubleLock, so that you
could write:
new SetLock(s).lockInvoke(r)
The above line would hold a lock on every Object in s and only
then run the supplied Runnable. Hint: see Hint.
Last modified 16:59:13 CST 03 March 2003
by Ron K. Cytron