⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 semaphore.java

📁 j2me 上面flash播放器。非常值得研究。就是版本只到2.0
💻 JAVA
字号:
package org.jflashme;/*  This library is free software; you can redistribute it and/or modify it *  under the terms of the GNU Lesser General Public License, version 2, as *  published by the Free Software Foundation. * *  This library is distributed in the hope that it will be useful, but *  WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *  Lesser General Public License (the accompanying file named LGPL.txt) *  for more details. */final class Semaphore{   private boolean state;    Semaphore(boolean flag)    {        state = flag;    }    synchronized boolean isSet()    {        return state;    }    synchronized void waitForTrue()        throws InterruptedException    {        while(!state)             wait();    }    synchronized void waitForEvent()        throws InterruptedException    {        while(!state)             wait();        state = false;    }    synchronized void set()    {        if(!state)            state = true;        notifyAll();    }    synchronized boolean clear()    {        boolean flag = state;        state = false;        return flag;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -