package os; /** * Title: Sistemas Operacionais * Description: Esta clase implementa uma lista duplamente encadeada e * sincronizada. * Copyright: Copyright (c) 2001 * Company: CRISUNsoft * @author CRISUN * @version 1.0 */ import java.util.*; public class Stack { private LinkedList buffer = new LinkedList(); /** * Remove um elemento no inicio da lista */ public synchronized char remove() { while (buffer.isEmpty()) { try { this.wait(); } catch (InterruptedException e) { } } return ((Character)buffer.removeFirst()).charValue(); } /** * Insere um elemento no final da lista */ public synchronized void add(char c) { buffer.addLast(new Character(c)); this.notify(); } }