18.07.2013 Views

Pemrograman Banyak Thread - Komputasi

Pemrograman Banyak Thread - Komputasi

Pemrograman Banyak Thread - Komputasi

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

class queue {<br />

private final static int SIZE = 10;<br />

int array[ ] = new int[SIZE];<br />

int r = 0; int w = 0; int count = 0;<br />

synchronized void add(int i) {<br />

//menunggu selama antrian (queue) penuh<br />

while (count == SIZE) {<br />

try { wait( );}<br />

catch (InterruptedException ie) {<br />

ie.printStackTrace( );<br />

System.exit(0);<br />

}<br />

} /* metode add */<br />

48

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!