本文整理汇总了Golang中github.com/zxh0/jvm/go/jvmgo/jvm/rtda.Thread.JThread方法的典型用法代码示例。如果您正苦于以下问题:Golang Thread.JThread方法的具体用法?Golang Thread.JThread怎么用?Golang Thread.JThread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/zxh0/jvm/go/jvmgo/jvm/rtda.Thread
的用法示例。
在下文中一共展示了Thread.JThread方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: mainThreadNotReady
func mainThreadNotReady(thread *rtda.Thread) bool {
stack := thread.CurrentFrame().OperandStack()
if _mainThreadGroup == nil {
undoExec(thread)
threadGroupClass := _classLoader.LoadClass("java/lang/ThreadGroup")
_mainThreadGroup = threadGroupClass.NewObj()
initMethod := threadGroupClass.GetConstructor("()V")
stack.PushRef(_mainThreadGroup) // this
thread.InvokeMethod(initMethod)
return true
}
if thread.JThread() == nil {
undoExec(thread)
threadClass := _classLoader.LoadClass("java/lang/Thread")
mainThreadObj := threadClass.NewObjWithExtra(thread)
mainThreadObj.SetFieldValue("priority", "I", int32(1))
thread.HackSetJThread(mainThreadObj)
initMethod := threadClass.GetConstructor("(Ljava/lang/ThreadGroup;Ljava/lang/String;)V")
stack.PushRef(mainThreadObj) // this
stack.PushRef(_mainThreadGroup) // group
stack.PushRef(rtda.JString("main")) // name
thread.InvokeMethod(initMethod)
return true
}
return false
}
示例2: Loop
// todo
func Loop(thread *rtda.Thread) {
threadObj := thread.JThread()
isDaemon := threadObj != nil && threadObj.GetFieldValue("daemon", "Z").(int32) == 1
if !isDaemon {
keepalive.NonDaemonThreadStart()
}
_loop(thread)
// terminate thread
threadObj = thread.JThread()
threadObj.Monitor().NotifyAll()
if !isDaemon {
keepalive.NonDaemonThreadStop()
}
}