sequencepoint / J2ME_MPEG

MPEG decoder for J2ME

Clone this repository (size: 438.8 KB): HTTPS / SSH
$ hg clone http://code.seqpoint.com/j2me_mpeg
commit 1: 01984a0b5939
parent 0: 9a1b9408acac
branch: default
tags: tip
Fixed license text
sequencepoint
8 months ago
J2ME_MPEG / Queue.java
r1:01984a0b5939 39 loc 992 bytes embed / history / annotate / raw /
/*
 * J2ME_MPEG: MPEG-1 decoder for J2ME
 *
 * Copyright (c) 2009 Sequence Point Software S.L.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */

import java.util.Vector;

public class Queue {
    private Vector queue = new Vector();

    public void put(Object obj) {
        synchronized (queue) {
            queue.addElement(obj);
            queue.notify();
        }
    }
 
    public Object get() {
        synchronized (queue) {
            while (queue.isEmpty()) {
                try {
                    queue.wait();
                }
                catch (InterruptedException ignore) {}
            }

            Object obj = queue.firstElement();
            queue.removeElementAt(0);
            return obj;
        }
    }
}