亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? conditionalactionrunner.java

?? 手機郵箱撒的方式方式方式的
?? JAVA
字號:
/*MujMail - Simple mail client for J2MECopyright (C) 2009 David Hauzar <david.hauzar.mujmail@gmail.com>This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */package mujmail.tasks;import java.util.Enumeration;import java.util.Vector;import mujmail.MujMail;import mujmail.util.Callback;import mujmail.util.Condition;import mujmail.util.Functions;import mujmail.util.Observable;import mujmail.util.Observer;/** * Runs given action when given condition is true. The condition is checked * every time some task is started or terminated. * * It is guaranteed that between testing the condition and doing the action * no task is started and no task is terminated. * Than, it is ensured that between testing the condition and doing the action * no condition of other instance of <code>ConditionalActionRunner</code> is * tested and no action of other instance of <code>ConditionalActionRunner</code> * is started. * * Ensures that the action is done only once. * * @author David Hauzar */public class ConditionalActionRunner implements Observer {    /** Flag signals if we want to print debug prints */    protected static final boolean DEBUG = false;    private final Callback action;    private final Condition condition;    private boolean actionWasDone = false;    private Callback actionWhenConditionNotHolds;    /**     * Creates the instance of ConditionalActionRunner.     * @param condition the condition that will be checked     * @param action the action that will be runned if the condition is true.     */    public ConditionalActionRunner(Condition condition, Callback action) {        this.condition = condition;        this.action = action;            }    /**     * Conditionally starts the action. That means that it checks whether the     * condition holds. If it holds, starts the action. If not, runs the action     * <code>actionWhenConditionNotHolds</code> and waits for the start or     * termination of some task to check the condition again.     *     * @param actionWhenConditionNotHolds the action that will be runned if the     *  condition does not hold before waiting for the next checking of the     *  condition.     */    public void startAction(Callback actionWhenConditionNotHolds) {        this.actionWhenConditionNotHolds = actionWhenConditionNotHolds;        actionWasDone = false;        registerObservers();        if (!testConditionAndDoAction(this, new ConditionArgument(), actionWhenConditionNotHolds)) {            actionWhenConditionNotHolds.callback(this, null);            return;        }    }    /**     * Tests the condition and if the condition holds, do the action.     * This method is synchronized so only one instance of this class can test     * the condition and do the action in one time.     * Ensures that no task is started and no task terminates between testing     * the condiotion and doing the action.     *      * @param actionRunner the action runner that condition will be tested and     *  that action could be done.     * @param conditionArgument the argument of the condition.     * @return true if the condtion holded and the action was done.     */    private static synchronized boolean testConditionAndDoAction(ConditionalActionRunner actionRunner, ConditionArgument conditionArgument, Callback actionWhenConditionNotHolds) {        BackgroundTask.disableStartingTasks();        BackgroundTask.disableTerminatingTasks();        if (actionRunner.actionWasDone) return true;        boolean result = actionRunner.condition.condition(conditionArgument);        if (result) {            if (actionWhenConditionNotHolds instanceof ConditionalActionRunnerUI) {                ((ConditionalActionRunnerUI)actionWhenConditionNotHolds).cancelDisplaying();            }            actionRunner.doTheAction();        }        BackgroundTask.enableStartingTasks();        BackgroundTask.enableTerminatingTasks();        return result;    }    /**     * Do the action without checking the condition.     * The action can be done only once so unregisters the this conditional     * action runner to don't check the condition when some task is started     * or terminated.     *      */    public void doTheAction() {        cancelAction();        if (DEBUG) System.out.println("do the action: " + this);        if (!actionWasDone) {            if (DEBUG) System.out.println("doing action");            action.callback(this, null);            actionWasDone = true;        }    }    /**     * Conditionally starts the action. That means that it checks whether the     * condition holds. If it holds, starts the action. If not, waits for the     * start or termination of some task to check the condition again.     */    public void startAction() {        startAction(Callback.NO_ACTION);    }    public synchronized void update(Observable o, Object arg) {        if (DEBUG) System.out.println("Update called");        ConditionArgument conditionArgument = new ConditionArgument();        conditionArgument.task = (BackgroundTask) arg;        if (o == TasksManager.endTaskObservable) {            conditionArgument.conditionCheckingReason = ReasonsForCheckingCondition.TERMINATED;        } else {            conditionArgument.conditionCheckingReason = ReasonsForCheckingCondition.STARTED;        }        testConditionAndDoAction(this, conditionArgument, actionWhenConditionNotHolds);    }    /**     * Cancels the action.     *      * This conditional action runner will not check the condition when some     * task will started or terminated.     */    public void cancelAction() {        if (DEBUG) System.out.println("cancel action" + this);        unregisterObservers();    }    /**     * Registers this object to update itself every time some task is started     * or terminated.     */    protected void registerObservers() {        TasksManager.addEndTaskObserver(this);        TasksManager.addStartTaskObserver(this);    }    /**     * Unregisters this object to not update itself every time some task is     * started or terminated.     */    protected void unregisterObservers() {        TasksManager.deleteEndTaskObserver(this);        TasksManager.deleteStartTaskObserver(this);    }    /**     * Object of this class is possed as argument to method     * {@link mujmail.util.Condition#condition(java.lang.Object)}     */    public static class ConditionArgument {        /** The task that caused checking of the condition. Null if this is initiall checking of the condition. */        public BackgroundTask task = null;        /** Why is the condition checked. */        public ReasonsForCheckingCondition conditionCheckingReason = ReasonsForCheckingCondition.INITIAL;    }    /**     * Enumeration class with reasons of checking of the condition.     */    public static class ReasonsForCheckingCondition {        private ReasonsForCheckingCondition() {};        /** Initial checking of the condition. */        public static ReasonsForCheckingCondition INITIAL = new ReasonsForCheckingCondition();        /** The condition is checked because some task started. */        public static ReasonsForCheckingCondition STARTED = new ReasonsForCheckingCondition();        /** The condition is checked because some task terminated. */        public static ReasonsForCheckingCondition TERMINATED = new ReasonsForCheckingCondition();    }    /**     * The condition for exiting application. The number of incompleted task     * must be zero.     * Singleton class with one instance condition.     */    public static class ExitApplicationCondition implements Condition {        private ExitApplicationCondition() {};        /** The condition when the application can be terminated. */        public static final ExitApplicationCondition CONDITION = new ExitApplicationCondition();        public boolean condition(Object argument) {            if (TasksManager.isSomeTaskRunningOrWaitingToStart()) return false;            return true;        }    }    /**     * The action for exiting the application.     * Singleton class with one instance ACTION.     */    public static class ExitApplicationAction implements Callback {        private ExitApplicationAction() {};        /** The action that exits application. */        public static final ExitApplicationAction ACTION  = new ExitApplicationAction();        public void callback(Object called, Object message) {            MujMail.mujmail.destroyApp(false);        }    }    /**     * The condition for starting new task. The number of started task must be     * less then {@link TasksManager#MAXIMUM_NUMBER_OF_RUNNING_TASKS}.     */    public static class StartNewTaskCondition implements Condition {        private final BackgroundTask taskToStart;        //private boolean conditionalActionRunnerUIWasShown = false;        public StartNewTaskCondition(BackgroundTask taskToStart) {            this.taskToStart = taskToStart;        }        public synchronized boolean condition(Object argument) {                        ConditionArgument condArgument = (ConditionArgument) argument;            if (condArgument.conditionCheckingReason == ReasonsForCheckingCondition.STARTED) {                return false;            }            if (testCondition()) {                // TODO: not needed anymore because this funcitonality is done                // by ConditionalActionRunner and ConditionalActionRunnerUI.                //if (conditionalActionRunnerUIWasShown) {                    //cancelDisplayingConditionalActionRunnerUI();                //}                return true;            } else {                //conditionalActionRunnerUIWasShown = true;                return false;            }        }        private boolean testCondition() {            Enumeration tasks = TasksManager.getRunningTasks().elements();            int numberOfTasksOfTheSameClass = 0;            while (tasks.hasMoreElements()) {                BackgroundTask task = (BackgroundTask) tasks.nextElement();                if (DEBUG) System.out.println(task.getClass());                if (DEBUG) System.out.println(taskToStart.getClass());                if (task.getClass() == taskToStart.getClass()) {                    numberOfTasksOfTheSameClass++;                    if (numberOfTasksOfTheSameClass >= TasksManager.MAXIMUM_NUMBER_OF_RUNNING_TASKS) {                        return false;                    }                }            }                        return true;        }        //private void cancelDisplayingConditionalActionRunnerUI() {            //taskToStart.conditionalActionRunnerUI.cancelDisplaying();        //}    }    /**     * The action for starting new tasks the application.     */    public static class StartNewTaskAction implements Callback {        private final BackgroundTask taskToStart;        public StartNewTaskAction(BackgroundTask taskToStart) {            this.taskToStart = taskToStart;        }        public void callback(Object called, Object message) {            taskToStart.immediatelyStart();        }    }    /**     * Used to start tasks. Contains all tasks that are actually waiting to     * start.     */    public static class ConditionalTaskRunner extends ConditionalActionRunner {        private BackgroundTask task;        private static Vector waitingTasks = new Vector();        public ConditionalTaskRunner(BackgroundTask task) {            super(new StartNewTaskCondition(task),                new StartNewTaskAction(task));            this.task = task;        }        /**         * Gets tasks that are waiting to start.         * @return tasks that are waiting to start.         */        public static Vector getWaitingTasks() {            return waitingTasks;        }        protected void registerObservers() {             waitingTasks.addElement(task);            super.registerObservers();        }        protected void unregisterObservers() {            waitingTasks.removeElement(task);            super.unregisterObservers();        }        /**         * Gets the number of tasks waiting to start.         * @return the number of tasks waiting to start.         */        public static int getNumberOfTasksWaitingForStart() {            return waitingTasks.size();        }    }        public static class SampleTestTask extends StoppableBackgroundTask {        public SampleTestTask() {            super("Sample task");        }        public void doWork() {            while (true) {                System.out.println("Do work");                if (stopped()) {                    System.out.println("Task was stopped.");                    break;                }                Functions.sleep(500);            }            System.out.println("After while.");        }    }    public static class SampleTestTask2 extends StoppableBackgroundTask {        public SampleTestTask2() {            super("Sample task 2");        }        public void doWork() {            while (true) {                System.out.println("Do work 2");                if (stopped()) {                    System.out.println("Task was stopped. 2");                    break;                }                Functions.sleep(500);            }            System.out.println("After while. 2");        }    }    }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91麻豆精品91久久久久久清纯| 亚洲色图欧洲色图| 国产精品国产三级国产三级人妇| 亚洲一区中文在线| 国产精品一区久久久久| 欧美亚洲动漫精品| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 六月丁香婷婷久久| 91官网在线免费观看| 日本一区二区三区国色天香 | 久久久久久久久岛国免费| 亚洲一区二区三区中文字幕在线 | 99re成人精品视频| 国产日韩欧美麻豆| 精品一区二区免费| 日韩免费观看高清完整版| 亚洲国产人成综合网站| 色婷婷亚洲一区二区三区| 国产欧美一区二区三区网站| 狠狠色2019综合网| 亚洲精品在线观| 国产一区在线观看视频| xnxx国产精品| 久久国产精品99久久人人澡| 精品视频资源站| 亚洲国产精品自拍| 欧美日韩国产精选| 午夜精品一区二区三区三上悠亚| 欧美性色aⅴ视频一区日韩精品| 亚洲色图一区二区三区| 91蜜桃在线观看| 亚洲欧美二区三区| 91国产丝袜在线播放| 亚洲一区二区三区中文字幕| 欧美三级电影网| 午夜不卡av在线| 91精品久久久久久久99蜜桃| 免费在线看一区| 精品国产一区二区三区忘忧草| 久久se精品一区二区| 精品剧情在线观看| 国产高清久久久久| 中文字幕在线观看不卡视频| 99久久精品费精品国产一区二区| 亚洲色图都市小说| 欧美三电影在线| 日本美女视频一区二区| 久久综合成人精品亚洲另类欧美 | 色8久久精品久久久久久蜜| 一区二区三区视频在线看| 欧美婷婷六月丁香综合色| 亚洲电影一区二区| 日韩久久免费av| 国产成人在线视频网站| 亚洲免费观看高清完整版在线| 91老司机福利 在线| 天使萌一区二区三区免费观看| 日韩三级高清在线| 成人国产精品免费观看视频| 一区二区三区中文字幕电影| 欧美巨大另类极品videosbest | 国产真实乱偷精品视频免| 亚洲视频精选在线| 欧美一区欧美二区| 国产999精品久久久久久| 伊人婷婷欧美激情| 欧美成人一区二区三区| 色哟哟欧美精品| 裸体在线国模精品偷拍| 亚洲欧洲日韩一区二区三区| 欧美一区中文字幕| 成人免费观看视频| 日韩精品免费视频人成| 国产精品乱码一区二三区小蝌蚪| 欧美人动与zoxxxx乱| 成人蜜臀av电影| 久久精品国产**网站演员| 亚洲人成网站精品片在线观看| 日韩欧美一级二级三级| 在线亚洲高清视频| 国产精品1区2区3区在线观看| 亚洲sss视频在线视频| 国产精品丝袜久久久久久app| 3atv一区二区三区| 日本韩国欧美在线| 成人性视频免费网站| 蜜桃av一区二区三区电影| 夜夜爽夜夜爽精品视频| 国产欧美一区二区精品性色超碰| 91精品国产美女浴室洗澡无遮挡| 一本色道久久综合狠狠躁的推荐| 国产成人综合在线播放| 日本不卡在线视频| 亚洲高清不卡在线观看| 亚洲精品亚洲人成人网在线播放| 精品盗摄一区二区三区| 日韩视频一区二区三区| 欧美日韩久久久久久| 日本乱人伦aⅴ精品| 成人午夜av电影| 国产乱码精品一区二区三区av| 日韩国产成人精品| 三级一区在线视频先锋 | 欧美乱妇一区二区三区不卡视频| heyzo一本久久综合| 成人激情小说乱人伦| 国产91精品久久久久久久网曝门 | 国产精品情趣视频| 国产欧美一区在线| 久久久国产精品麻豆| 久久亚洲综合av| 久久综合色播五月| 久久伊99综合婷婷久久伊| 久久夜色精品国产欧美乱极品| 精品日本一线二线三线不卡| 精品国产91洋老外米糕| 日韩欧美一区二区久久婷婷| 日韩免费电影一区| 精品国产乱码久久| 精品成人免费观看| 久久蜜桃av一区精品变态类天堂| 欧美大度的电影原声| 欧美大胆人体bbbb| 国产亚洲精品超碰| 中文字幕一区二区三区在线观看 | 中文字幕一区二区三| 亚洲日本青草视频在线怡红院| 亚洲品质自拍视频| 一区二区久久久久| 水野朝阳av一区二区三区| 美女mm1313爽爽久久久蜜臀| 精品一区二区三区影院在线午夜| 国产一区二区在线看| 成人国产精品免费观看动漫| aaa国产一区| 欧美日韩国产一区二区三区地区| 日韩一区二区在线免费观看| 国产亚洲女人久久久久毛片| 亚洲三级理论片| 日韩有码一区二区三区| 国产麻豆欧美日韩一区| 91原创在线视频| 日韩视频123| 国产精品国产自产拍高清av王其| 亚洲亚洲人成综合网络| 久久99在线观看| 一本久久a久久免费精品不卡| 欧美精品久久久久久久多人混战| 精品国产制服丝袜高跟| 亚洲欧美视频在线观看| 久久成人av少妇免费| 91麻豆福利精品推荐| 日韩小视频在线观看专区| 国产精品成人免费| 奇米色777欧美一区二区| 99精品久久只有精品| 日韩一二三区视频| 一区二区中文视频| 久久99精品久久久久| 在线观看视频一区二区欧美日韩| 日韩精品专区在线| 一区二区免费在线| 成人毛片在线观看| 日韩一区二区不卡| 一区二区三区四区视频精品免费| 国产综合久久久久久久久久久久| 在线亚洲一区观看| 中文字幕不卡在线播放| 久久成人免费日本黄色| 欧美日韩一卡二卡三卡 | 久久久蜜臀国产一区二区| 亚洲一区二区三区四区五区黄 | 亚洲欧美精品午睡沙发| 国产在线精品一区二区夜色 | 欧美亚洲禁片免费| 国产精品久久久久影视| 激情小说欧美图片| 欧美伦理视频网站| 亚洲永久免费视频| 一本色道久久综合亚洲精品按摩| 欧美国产欧美综合| 国产九色sp调教91| 2020国产精品久久精品美国| 日本美女一区二区| 欧美日韩国产片| 亚洲国产综合在线| 在线精品视频小说1| 亚洲美女一区二区三区| 暴力调教一区二区三区| 国产精品久久看| 床上的激情91.| 国产欧美日韩精品一区| 国产xxx精品视频大全| 国产亚洲福利社区一区| 国产69精品一区二区亚洲孕妇| 久久亚洲欧美国产精品乐播| 久久99精品国产.久久久久久| 日韩欧美三级在线| 久久精品免费看| 日韩一卡二卡三卡四卡|