如题:

android开发 系统时间与定时器之间有关系嘛?

答案:有。

看定时器源码:

/*
     * Schedule a task.
     */
    private void scheduleImpl(TimerTask task, long delay, long period, boolean fixed) {
        synchronized (impl) {
            if (impl.cancelled) {
                throw new IllegalStateException("Timer was canceled");
            }

            long when = delay + System.currentTimeMillis();

            if (when < 0) {
                throw new IllegalArgumentException("Illegal delay to start the TimerTask: " + when);
            }

            synchronized (task.lock) {
                if (task.isScheduled()) {
                    throw new IllegalStateException("TimerTask is scheduled already");
                }

                if (task.cancelled) {
                    throw new IllegalStateException("TimerTask is canceled");
                }

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

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

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-10
  • 2021-11-22
  • 2022-12-23
  • 2021-06-20
  • 2021-06-22
  • 2022-01-15
猜你喜欢
  • 2022-12-23
  • 2022-02-10
  • 2021-05-21
  • 2021-04-08
  • 2022-12-23
  • 2021-10-08
  • 2021-11-19
相关资源
相似解决方案