admin管理员组

文章数量:1125610

How to introduce Cangjie-lang's spawn thread into ArkTs-lang? As ArkTs/Ts/Js's ThreadPool is too complicated for me.

maybe a testSpawn interface can be implemented like testCJ does, allowing ArkTs/Ts/Js code run in it:

package ohos_app_cangjie_entry

internal import ohos.ark_interop.JSModule
internal import ohos.ark_interop.JSContext
internal import ohos.ark_interop.JSCallInfo
internal import ohos.ark_interop.JSValue
internal import cj_res_entry.app

func testCJ(runtime: JSContext, callInfo: JSCallInfo): JSValue {
    let value = callInfo[0].toString(runtime)
    let result = "Hello ${value}"
    runtime.string(result).toJSValue()
}

let EXPORT_MODULE = JSModule.registerModule {
    runtime, exports => exports["testCJ"] = runtime.function(testCJ).toJSValue()
}

本文标签: multithreadingHow to introduce Cangjielang39s spawn thread into ArkTslangStack Overflow