java - 用于在启动时插入数据的并行流
问题描述
我只是想知道是否可以在启动事件函数中创建一个 parallelStream。我现在发现了 quarkus,为了进行测试,我必须在启动时读取一个文件并将其文件插入到数据库中。每当尝试使用 aparallelStream
而不是普通的时,我都会得到ACCESS_VIOLATION_EXCEPTION
.
这是一些代码,因此您可以想象我在做什么。这个例子有效。
void onStart(@Observes StartupEvent ev) throws Exception {
// Parsing the file, getting the iterator
it.readAll().stream().forEach(this::operateEntry);
}
@Transactional
void operateEntry(Entry entry) {
// Performing the database actions for a single entry
}
使用相同的示例,但这次使用并行流会导致错误:
void onStart(@Observes StartupEvent ev) throws Exception {
// Parsing the file, getting the iterator
it.readAll().parallelStream().forEach(this::operateEntry);
}
和错误信息
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffd5e59bf40, pid=15880, tid=20388
#
# JRE version: Java(TM) SE Runtime Environment (11.0.1+13) (build 11.0.1+13-LTS)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (11.0.1+13-LTS, mixed mode, tiered, compressed oops, g1 gc, windows-amd64)
# Problematic frame:
# V [jvm.dll+0x1ebf40]
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# D:\knowledge\curator-service\target\hs_err_pid15880.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
我知道在每个 quarkus 启动时解析大量数据可能不是一个现实的用例。但是我想了解为什么这不起作用。我很感谢任何建议。
先感谢您。
解决方案
推荐阅读
- typescript - 如何在打字稿中使用 rxjs6 分区?
- angular - BehaviorSubject 冷漠的行为
- java - Android:如何像 truecaller 一样将我的应用添加到默认手机应用列表
- c++ - 仍在评估废弃分支中的嵌套 constexpr-if 语句?
- java - 执行加载命令时出错:org.hibernate.exception.GenericJDBCException:无法准备语句
- flutter - 在颤动中添加图像作为背景
- java - Java/Groovy:用类初始化方法的优雅方式
- java - 卷曲与 aem 的身份验证
- angular - 错误类型错误:无法读取未定义的属性“类别”
- python - 跨度元素没有用撇号替换 '