JPDA Architecture Research 6-agent using environment pointers to access VMS (thread management chapter)

Source: Internet
Author: User

Introduced:

The previous article explained the classification: memory management, now the interface for threading class operations.


Category 2: Threading class operations

A.getthreadstate. Getting thread Status

Jvmtierrorgetthreadstate (jvmtienv* env, Jthread thread, jint* thread_state_ptr)

We all know that threads have many kinds of states, such as alive,terminated,runnable, waiting to enter synchronize block,waiting,sleeping,parked,suspended,interrupted and so on.

It takes the parameter thread to indicate the threads to query, and returns THREAD_STATE_PTR to indicate the thread state.


B.getallthreads. Get all the live threads, these threads must be connected to the current VM and alive.

Jvmtierrorgetallthreads (jvmtienv* env, jint* threads_count_ptr, jthread** threads_ptr)

It returns threads_count_ptr that represents the number of threads alive, and returns a reference array that threads_ptr represents a live thread.


C.suspendthread. Suspending a thread

Jvmtierrorsuspendthread (jvmtienv* env, Jthread thread)

Once a thread is suspended, the corresponding method cannot return until another thread calls ResumeThread.

It takes the parameter thread to indicate which threads to suspend.


D.suspendthreadlist. Suspending a group of threads

Jvmtierrorsuspendthreadlist (jvmtienv* env, Jint request_count, const jthread* request_list, jvmtierror* results)

Once a thread is suspended in threadlist, only one of the other threads is called resumethreadlist or ResumeThread, and the corresponding method can be returned.

The Enter parameter Request_count represents the number of threads to suspend, Request_list, which represents the array of threads to suspend, and returns results that represents the pending result.


E.resumethread. Recovering a suspended thread

Jvmtierrorresumethread (jvmtienv* env, Jthread thread)


F.resumethreadlist. Recovering a suspended thread group

Jvmtierrorresumethreadlist (jvmtienv* env, Jint request_count, const jthread* request_list, jvmtierror* results)


G.stopthread. Kill a Thread

Jvmtierrorstopthread (jvmtienv* env, Jthread thread, Jobject exception)


H.interruptthread. Interrupting a thread

Vmtierrorinterruptthread (jvmtienv* env, Jthread thread)


I.getthreadinfo. Getting information about a thread

typedef struct {char* name; Jint    Priority    Jboolean Is_daemon;    Jthreadgroup Thread_group; Jobject Context_class_loader;} Jvmtithreadinfo;
Jvmtierrorgetthreadinfo (jvmtienv* env, Jthread thread, jvmtithreadinfo* info_ptr)

As you can see here, you can get the name of the thread, the priority, whether the daemon thread, the owning thread group, the context loader, and so on.


J.getownermonitorinfo. Getting a thread-owned monitor (can have multiple) information

Jvmtierrorgetownedmonitorinfo (jvmtienv* env, Jthread thread, jint* owned_monitor_count_ptr, jobject** owned_monitors_ptr)

My understanding of monitor here is the lock the thread holds, which is the object associated with the synchronized.

The incoming parameter is still a given thread, returning the number of monitors and an array of monitor references.


K.getcurrentcontendedmonitor. Gets the current monitor for the thread.

Jvmtierrorgetcurrentcontendedmonitor (jvmtienv* env, Jthread thread, jobject* monitor_ptr)

And the use of the above supporting. Because multiple competitors share a thread at the same time, there must be a current competitor that occupies the execution of this thread.


L.SETTHREADLOCALSTORAGE.VM sets a thread-local value to associate to an environment-thread pair.

Jvmtierrorsetthreadlocalstorage (jvmtienv* env, jthread thread, const void* data)


M.getthreadlocalstorage.agent to get the thread-local value set for a thread.

Jvmtierrorgetthreadlocalstorage (jvmtienv* env, Jthread thread, void** data_ptr)




This article is from the "cohesion of parallel Lines" blog, please be sure to keep this source http://supercharles888.blog.51cto.com/609344/1587694

JPDA Architecture Research 6-agent using environment pointers to access VMS (thread management chapter)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.