This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p>There are three threading problems listed <a href="http://www.d.umn.edu/~cprince/courses/cs5631spring10/lectures/ThreadAndSynch.pdf">here</a>. Do all three of them (separately).</p> | |
<p>This will be due by next Wednesday, Dec. 14th. But, I want you to show me the running code instead of submitting it. Let me know before Monday when you can see me next week.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// partition2.java | |
// demonstrates partitioning an array | |
// uses highest-index (right) element as pivot | |
// to run this program: C>java PartitionApp | |
//////////////////////////////////////////////////////////////// | |
class ArrayPar | |
{ | |
private long[] theArray; // ref to array theArray | |
private int nElems; // number of data items | |
//-------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LineDrawer { | |
float x1, y1, x2, y2; | |
boolean movingForward; | |
void drawItself() { | |
line (x1, y1, x2, y2); | |
} | |
void update() { | |
if (movingForward) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MovingBall { | |
float x, y, w, maxW, speed; // variables for drawing the ellipse | |
boolean movingForward; | |
boolean movingUp; | |
boolean expanding; | |
boolean mouseInside; | |
float r, g, b; | |
void drawItself() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Box { | |
float x, y, w, h, speed; | |
boolean movingForward, movingUp; | |
void drawItself() { | |
rect(x, y, w, h); | |
} | |
void update() { | |
if (movingForward) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CircleDraw { | |
float x, y, r, a; | |
void drawSelf() { | |
fill(255); | |
noStroke(); | |
ellipse(x + r * cos(a), y - r * sin (a), 5, 5); | |
a += 0.1; | |
if (a >= 2 * PI) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Box { | |
float x, y, w, h; | |
void drawItself() { | |
rect(x, y, w, h); | |
} | |
} | |
Box myBox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MovingBall { | |
float x, y, w, maxW, speed; // variables for drawing the ellipse | |
boolean movingForward; | |
boolean movingUp; | |
boolean expanding; | |
float r, g, b; | |
void drawItself() { | |
fill(r, g, b); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Mask with least signficant n bits set to 1 | |
* Examples: n = 6 --> 0x2F, n = 17 --> 0x1FFFF | |
* Assume 1 <= n <= w | |
*/ | |
int lower_one_mask(int n) { | |
/* | |
* 2ˆn-1 has bit pattern 0...01..1 (n 1’s) | |
* But, we must avoid a shift by 32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MovingBall { | |
float x, y, w; // variables for drawing the ellipse | |
boolean movingForward; | |
boolean movingUp; | |
void drawItself() { | |
ellipse(x, y, w, w); | |
} | |