diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc index e8a24ce8da5a59daaf60edbac4aa47927f8c0dcc..0b90532635d9a39a0e7f9b896f816795a0927552 100644 --- a/src/js_native_api_v8.cc +++ b/src/js_native_api_v8.cc @@ -1,5 +1,6 @@ #include #include +#include #include // INT_MAX #include #include "v8-debug.h" @@ -1349,6 +1350,11 @@ v8::Platform* JSVM_Env__::platform() { JSVM_Status JSVM_CDECL OH_JSVM_Init(const JSVM_InitOptions* options) { + static std::atomic initialized(false); + if (initialized.load()) { + return JSVM_GENERIC_FAILURE; + } + initialized.store(true); #ifdef TARGET_OHOS v8impl::ResourceSchedule::ReportKeyThread(getuid(), getprocpid(), getproctid(), v8impl::ResourceSchedule::ResType::ThreadRole::IMPORTANT_DISPLAY);