本文整理了Java中java.lang.RuntimeException
类的一些代码示例,展示了RuntimeException
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RuntimeException
类的具体详情如下:
包路径:java.lang.RuntimeException
类名称:RuntimeException
[英]RuntimeException is the superclass of all classes that represent exceptional conditions which occur as a result of executing an application in the VM. Unlike checked exceptions (exceptions where the type doesn't extend RuntimeException or Error), the compiler does not require code to handle runtime exceptions.
[中]RuntimeException是所有类的超类,这些类表示在VM中执行应用程序时出现的异常情况。与检查异常(类型不扩展RuntimeException或Error的异常)不同,编译器不需要代码来处理运行时异常。
代码示例来源:origin: ReactiveX/RxJava
static void sleep(int millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException ex) {
throw new RuntimeException(ex);
}
}
}
代码示例来源:origin: ReactiveX/RxJava
protected void captureMaxThreads() {
int concurrentThreads = threadsRunning.get();
int maxThreads = maxConcurrentThreads.get();
if (concurrentThreads > maxThreads) {
maxConcurrentThreads.compareAndSet(maxThreads, concurrentThreads);
if (concurrentThreads > 1) {
new RuntimeException("should not be greater than 1").printStackTrace();
}
}
}
代码示例来源:origin: iluwatar/java-design-patterns
@Override
public void run() {
try (Socket socket = new Socket(InetAddress.getLocalHost(), serverPort)) {
OutputStream outputStream = socket.getOutputStream();
PrintWriter writer = new PrintWriter(outputStream);
sendLogRequests(writer, socket.getInputStream());
} catch (IOException e) {
LOGGER.error("error sending requests", e);
throw new RuntimeException(e);
}
}
代码示例来源:origin: ReactiveX/RxJava
protected void captureMaxThreads() {
int concurrentThreads = threadsRunning.get();
int maxThreads = maxConcurrentThreads.get();
if (concurrentThreads > maxThreads) {
maxConcurrentThreads.compareAndSet(maxThreads, concurrentThreads);
if (concurrentThreads > 1) {
new RuntimeException("should not be greater than 1").printStackTrace();
}
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public SingleSource<Integer> apply(final Integer integer) throws Exception {
throw new RuntimeException("something went terribly wrong!");
}
})
代码示例来源:origin: ReactiveX/RxJava
@Override
public Flowable<Integer> apply(Integer t1) {
throw new RuntimeException("Forced failure");
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public Integer apply(Integer t1, Integer t2) {
throw new RuntimeException("Forced failure");
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public Observable<Integer> apply(Integer t1) {
throw new RuntimeException("Forced failure");
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public Flowable<Integer> apply(Integer t1) {
throw new RuntimeException("Forced failure");
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public T apply(Integer t1) {
throw new RuntimeException("Forced failure");
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public Long apply(Long value) {
if (value == 1L) {
throw new RuntimeException("error!");
}
return value;
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public Throwable call() {
return new RuntimeException();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public R apply(T t1) {
throw new RuntimeException("Forced failure");
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public void run() {
throw new RuntimeException("failed on second one too");
}
}));
代码示例来源:origin: ReactiveX/RxJava
@Override
public Map<Integer, String> call() {
throw new RuntimeException("Forced failure");
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public void accept(Long n) {
throw new RuntimeException();
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onError(Throwable e) {
throw new RuntimeException(e);
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public void accept(Throwable e) {
if (++calls == 3) {
throw new RuntimeException();
}
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public String apply(String v1, String v2) {
throw new RuntimeException("I don't work.");
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(Long args) {
throw new RuntimeException("forced failure");
}
};
内容来源于网络,如有侵权,请联系作者删除!