org.springframework.scheduling.annotation.Async.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(186)

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

Async.<init>介绍

暂无

代码示例

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

@Async
public interface AsyncInterface {
  void doSomething(int i);
  Future<String> returnSomething(int i);
}

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

@Async
public static class AsyncClassListener implements ApplicationListener<ApplicationEvent> {
  public AsyncClassListener() {
    listenerConstructed++;
  }
  @Override
  public void onApplicationEvent(ApplicationEvent event) {
    listenerCalled++;
    assertTrue(!Thread.currentThread().getName().equals(originalThreadName));
  }
}

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

@Async
  @Override
  public void doIt() {
  }
}

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

@Async
public static class AsyncClassBeanWithInterface implements RegularInterface {
  public void doSomething(int i) {
    assertTrue(!Thread.currentThread().getName().equals(originalThreadName));
  }
  public Future<String> returnSomething(int i) {
    assertTrue(!Thread.currentThread().getName().equals(originalThreadName));
    return new AsyncResult<>(Integer.toString(i));
  }
}

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

@Async
  @Override
  public void doIt() {
  }
}

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

@Async
@Override
public Future<Object> failWithFuture() {
  throw new UnsupportedOperationException("failWithFuture");
}

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

@Async
@Override
public ListenableFuture<Object> failWithListenableFuture() {
  throw new UnsupportedOperationException("failWithListenableFuture");
}

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

@Async
@Override
public void failWithVoid() {
  throw new UnsupportedOperationException("failWithVoid");
}

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

@Override
@Async
public void test() {
  this.thread = Thread.currentThread();
  this.latch.countDown();
}

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

@EventListener
  @Async
  public void handleAsync(AnotherTestEvent event) {
    collectEvent(event);
    if ("fail".equals(event.content)) {
      this.countDownLatch.countDown();
      throw new IllegalStateException("Test exception");
    }
  }
}

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

@Async
  public CompletableFuture<String> returnSomethingCompletable(int i) {
    assertTrue(!Thread.currentThread().getName().equals(originalThreadName));
    if (i == 0) {
      throw new IllegalArgumentException();
    }
    return CompletableFuture.completedFuture(Integer.toString(i));
  }
}

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

@Async("e2")
  public Future<Thread> work3() {
    return new AsyncResult<>(Thread.currentThread());
  }
}

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

@Async
public CompletableFuture<String> returnSomethingCompletable(int i) {
  assertTrue(!Thread.currentThread().getName().equals(originalThreadName));
  if (i == 0) {
    throw new IllegalArgumentException();
  }
  return CompletableFuture.completedFuture(Integer.toString(i));
}

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

@Override
  @Async
  public void onApplicationEvent(ApplicationEvent event) {
    listenerCalled++;
    assertTrue(!Thread.currentThread().getName().equals(originalThreadName));
  }
}

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

@Async("e1")
public void doSomething(int i) {
  assertTrue(!Thread.currentThread().getName().equals(originalThreadName));
  assertTrue(Thread.currentThread().getName().startsWith("e1-"));
}

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

@EventListener
  @Async
  public void handleAsync(AnotherTestEvent event) {
    assertTrue(!Thread.currentThread().getName().equals(event.content));
    collectEvent(event);
    this.countDownLatch.countDown();
  }
}

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

@EventListener
  @Async
  public void handleAsync(AnotherTestEvent event) {
    assertTrue(!Thread.currentThread().getName().equals(event.content));
    this.eventCollector.addEvent(this, event);
    this.countDownLatch.countDown();
  }
}

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

@EventListener
  @Async
  public void handleAsync(AnotherTestEvent event) {
    assertTrue(!Thread.currentThread().getName().equals(event.content));
    this.eventCollector.addEvent(this, event);
    this.countDownLatch.countDown();
  }
}

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

@Async
public ListenableFuture<String> returnSomethingListenable(int i) {
  assertTrue(!Thread.currentThread().getName().equals(originalThreadName));
  if (i == 0) {
    throw new IllegalArgumentException();
  }
  else if (i < 0) {
    return AsyncResult.forExecutionException(new IOException());
  }
  return new AsyncResult<>(Integer.toString(i));
}

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

@Async
public Future<String> returnSomething(int i) {
  assertTrue(!Thread.currentThread().getName().equals(originalThreadName));
  if (i == 0) {
    throw new IllegalArgumentException();
  }
  else if (i < 0) {
    return AsyncResult.forExecutionException(new IOException());
  }
  return AsyncResult.forValue(Integer.toString(i));
}

相关文章