java.lang.Runnable.run()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(231)

本文整理了Java中java.lang.Runnable.run方法的一些代码示例,展示了Runnable.run的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Runnable.run方法的具体详情如下:
包路径:java.lang.Runnable
类名称:Runnable
方法名:run

Runnable.run介绍

[英]Starts executing the active part of the class' code. This method is called when a thread is started that has been created with a class which implements Runnable.
[中]开始执行类代码的活动部分。当使用实现Runnable的类创建的线程启动时,将调用此方法。

代码示例

代码示例来源:origin: ReactiveX/RxJava

void doTerminate() {
  Runnable r = onTerminate.get();
  if (r != null && onTerminate.compareAndSet(r, null)) {
    r.run();
  }
}

代码示例来源:origin: iluwatar/java-design-patterns

private void processPendingCommands() {
 Iterator<Runnable> iterator = pendingCommands.iterator();
 while (iterator.hasNext()) {
  Runnable command = iterator.next();
  command.run();
  iterator.remove();
 }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public void run() {
  runner = Thread.currentThread();
  try {
    decoratedRun.run();
  } finally {
    dispose();
    runner = null;
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public void execute(Runnable r) {
    r.run();
  }
}, true);

代码示例来源:origin: ReactiveX/RxJava

@Override
  public Void call() throws Exception {
    runner = Thread.currentThread();
    try {
      runnable.run();
    } finally {
      lazySet(FINISHED);
      runner = null;
    }
    return null;
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public void execute(Runnable r) {
    r.run();
  }
}, true);

代码示例来源:origin: ReactiveX/RxJava

@Override
  public void run() {
    firstStepStart.run();
    firstStepEnd.run();
    latch.countDown();
  }
};

代码示例来源:origin: ReactiveX/RxJava

public void executeOne() {
  Runnable r = queue.poll();
  if (r != null) {
    r.run();
  }
}
public void executeAll() {

代码示例来源:origin: ReactiveX/RxJava

public void executeOne() {
  Runnable r = queue.poll();
  if (r != null) {
    r.run();
  }
}
public void executeAll() {

代码示例来源:origin: ReactiveX/RxJava

public void executeAll() {
    Runnable r;
    while ((r = queue.poll()) != null) {
      r.run();
    }
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public void run() {
    thirdStepStart.run();
    inner.schedule(secondAction);
    thirdStepEnd.run();
  }
};

代码示例来源:origin: ReactiveX/RxJava

@Override
  public void run() {
    secondStepStart.run();
    inner.schedule(firstAction);
    secondStepEnd.run();
  }
};

代码示例来源:origin: ReactiveX/RxJava

@NonNull
@Override
public Disposable schedule(@NonNull Runnable run) {
  run.run();
  return DISPOSED;
}

代码示例来源:origin: ReactiveX/RxJava

@NonNull
@Override
public Disposable scheduleDirect(@NonNull Runnable run) {
  run.run();
  return DISPOSED;
}

代码示例来源:origin: ReactiveX/RxJava

@NonNull
@Override
public Disposable scheduleDirect(@NonNull Runnable run, long delay, TimeUnit unit) {
  try {
    unit.sleep(delay);
    RxJavaPlugins.onSchedule(run).run();
  } catch (InterruptedException ex) {
    Thread.currentThread().interrupt();
    RxJavaPlugins.onError(ex);
  }
  return EmptyDisposable.INSTANCE;
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public Disposable schedule(Runnable run, long delay,
      TimeUnit unit) {
    run.run();
    return Disposables.empty();
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public void run() {
  if (!disposed) {
    try {
      run.run();
    } catch (Throwable ex) {
      Exceptions.throwIfFatal(ex);
      worker.dispose();
      throw ExceptionHelper.wrapOrThrow(ex);
    }
  }
}

代码示例来源:origin: ReactiveX/RxJava

@NonNull
@Override
public Disposable schedule(@NonNull Runnable action) {
  action.run();
  return mockDisposable; // this subscription is returned but discarded
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void disposedUpfront() {
  Runnable run = mock(Runnable.class);
  Maybe.fromRunnable(run)
  .test(true)
  .assertEmpty();
  verify(run, never()).run();
}

代码示例来源:origin: ReactiveX/RxJava

@NonNull
@Override
public Disposable schedule(@NonNull Runnable action, long delayTime, @NonNull TimeUnit unit) {
  action.run();
  return mockDisposable;
}

相关文章