Exemplo n.º 1
0
        /*
         * Schedule a task.
         */
        private void scheduleImpl(TimerTask task, long delay, long period,
                                  bool fixedJ)
        {
            lock (impl) {
                if (impl.cancelled)
                {
                    throw new java.lang.IllegalStateException("Timer was cancelled"); //$NON-NLS-1$
                }

                long when = delay + java.lang.SystemJ.currentTimeMillis();

                if (when < 0)
                {
                    throw new java.lang.IllegalArgumentException("Illegal delay to start the TimerTask"); //$NON-NLS-1$
                }

                lock (task.lockJ) {
                    if (task.isScheduled())
                    {
                        throw new java.lang.IllegalStateException("TimerTask is scheduled already"); //$NON-NLS-1$
                    }

                    if (task.cancelled)
                    {
                        throw new java.lang.IllegalStateException("TimerTask is cancelled"); //$NON-NLS-1$
                    }

                    task.when      = when;
                    task.period    = period;
                    task.fixedRate = fixedJ;
                }

                // insert the newTask into queue
                impl.insertTask(task);
            }
        }
Exemplo n.º 2
0
        /*
            * Schedule a task.
            */
        private void scheduleImpl(TimerTask task, long delay, long period,
                bool fixedJ)
        {
            lock (impl) {
                if (impl.cancelled) {
                    throw new java.lang.IllegalStateException("Timer was cancelled"); //$NON-NLS-1$
                }

                long when = delay + java.lang.SystemJ.currentTimeMillis();

                if (when < 0) {
                    throw new java.lang.IllegalArgumentException("Illegal delay to start the TimerTask"); //$NON-NLS-1$
                }

                lock (task.lockJ) {
                    if (task.isScheduled()) {
                        throw new java.lang.IllegalStateException("TimerTask is scheduled already"); //$NON-NLS-1$
                    }

                    if (task.cancelled) {
                        throw new java.lang.IllegalStateException("TimerTask is cancelled"); //$NON-NLS-1$
                    }

                    task.when = when;
                    task.period = period;
                    task.fixedRate = fixedJ;
                }

                // insert the newTask into queue
                impl.insertTask(task);
            }
        }