java.lang.Runnable类的使用及代码示例

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

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

Runnable介绍

[英]Represents a command that can be executed. Often used to run code in a different Thread.
[中]表示可以执行的命令。通常用于在不同线程中运行代码。

代码示例

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

@Override
  public T call() throws Exception {
    runnable.run();
    return null;
  }
}

代码示例来源:origin: google/guava

@Override
public void setUp() throws Exception {
 if (setUp != null) {
  setUp.run();
 }
}

代码示例来源:origin: google/guava

@Override
 public void run() {
  task.run();
 }
};

代码示例来源:origin: google/guava

@Override
 public Void call() throws Exception {
  combiner.run();
  return null;
 }
},

代码示例来源:origin: google/guava

@Override
public void tearDown() throws Exception {
 if (tearDown != null) {
  tearDown.run();
 }
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Save model attributes in the session based on a type-level declarations
 * in an {@code @SessionAttributes} annotation.
 */
public void saveModel() {
  if (this.saveModelOperation != null) {
    this.saveModelOperation.run();
  }
}

代码示例来源:origin: spring-projects/spring-framework

private void invoke(List<Runnable> callbacks) {
  for (Runnable runnable : callbacks) {
    try {
      runnable.run();
    }
    catch (Throwable ex) {
      // ignore
    }
  }
}

代码示例来源:origin: spring-projects/spring-framework

private void decreaseActiveInvokerCount() {
  activeInvokerCount--;
  if (stopCallback != null && activeInvokerCount == 0) {
    stopCallback.run();
    stopCallback = null;
  }
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Delegates execution to the underlying Runnable.
 */
@Override
public void run() {
  this.delegate.run();
}

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

void doTerminate() {
  Runnable r = onTerminate.getAndSet(null);
  if (r != null) {
    r.run();
  }
}

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

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

代码示例来源:origin: spring-projects/spring-framework

/**
 * Invoke all registered destruction callbacks.
 * To be called on ServletContext shutdown.
 * @see org.springframework.web.context.ContextCleanupListener
 */
@Override
public void destroy() {
  for (Runnable runnable : this.destructionCallbacks.values()) {
    runnable.run();
  }
  this.destructionCallbacks.clear();
}

代码示例来源:origin: spring-projects/spring-framework

public void addDispatchHandler(Runnable handler) {
  Assert.notNull(handler, "Dispatch handler must not be null");
  synchronized (this) {
    if (this.dispatchedPath == null) {
      this.dispatchHandlers.add(handler);
    }
    else {
      handler.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 execute(Runnable r) {
    r.run();
  }
});

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

@Override
  public void run() {
    try {
      action.run();
    } finally {
      actionCompletable.onComplete();
    }
  }
}

相关文章