Preciso saber o q esse processo faz?

2 respostas
R
import java.util.*;

public class BoundedBuffer

{

public BoundedBuffer() {

// buffer rata inicialmente vazio

count = 0;

in = 0;

out = 0;

bufer = new Object[BUFFER_SIZE];

}
public void enter(Object item){
		//chama enter
	}
	
	public void remove(){
		//chama remove
	}

	public static final int NAP_TIME = 5;
	private static final int BUFFER_SIZE = 5;
	private volatiole int count;
	private int in; //aponta para a proxima possicao livre
	private int out; //aponta para a proxima possicao cheia
	private Object[ ] buffer;
}
////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////

public void enter(Object item) {

while(count == BUFFER_SIZE)

;  //nao faz nda
// adiciona um item ao buffer
	++count;
	buffer[in] = item;
	in = (in + 1) % BUFFER_SIZE;
	if (count == BUFFER_SIZE)
		System.out.println("Producer Entered "+ item + "Buffer FULL");
	else 
		System.out.println("Producer Entered "+ item + "Buffer Size = "+ count);
////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////

public Object remove() {

Object item;
while (count == 0)
			; // nao faz nda
		//remove um item do buffer
		--count;
		item = buffer[out];
		out = (out +1) % BUFFER_SIZE;
		
		if (count == 0)
			System.out.print("Consumer Consumed "+ item +" Buffer EMPTY");
		else 
			System.out.print("Consumer Consumed "+ item +" Buffer Size = "+ count);
		
		return item;
	}

2 Respostas

pcalcado

Uhm…esse título é uma pergunta?

Sei lá, me passou uma idéia doida pela cabeça…Que tal rodar o programa?

[]s

aborges

Em primeiro lugar, vc tem ver de onde vc tirou o danado … Provavelmente lah diga…

Caso contrario, tente entender a logica…

C mesmo assim, nao der, debuga ele e v passo a passo…

Pq vc quer saber o q ele faz ?

Criado 19 de abril de 2004
Ultima resposta 19 de abr. de 2004
Respostas 2
Participantes 3