Source resolve

1.1 The method of construction
of several common variables
group: thread group, thread group includes other groups of threads, a tree structure is formed, in addition to the initial thread group, the other group will have a parent thread, threads can access information for the current thread group, can not access parent thread group information
daemon: daemon thread,

 

 

 

We are actually running the init () method, we detail under this method

// ThreadGroup g, thread group, thread creation is added to the thread group, thread group is a collection of threads, thread groups form a tree, in addition to the initial set of threads, each thread group has a parent thread group
// Runnable target the method for the callback, thread's run () will turn off the target's run () method, which is really the thread processing transactions where
// String name name of the thread
// thread stack size stackSize created, if it is 0, indicating that this parameter is ignored
Private void the init (G ThreadGroup, Runnable target, String name, Long the stackSize) {
// call the function currentThread native layer to obtain the thread of the current environment in which, for example, in the Activity, you get will be the UI thread
Thread parent = currentThread (); // native method calls to the underlying code
IF (G == null) {
G = parent.getThreadGroup ();
}

g.addUnstarted (); // number of threads plus background. 1
this.group = G;

this.target = target;
this.priority = parent.getPriority();
this.daemon = parent.isDaemon();
setName(name);

init2(parent);

/ * Stash at The Stack size specified in CARES Case at The VM * /
this.stackSize = the stackSize;
tid = nextThreadID (); // // create a unique identity thread Id, thread
}

void INIT2 Private (the Thread parent) {
// Get parent class loader thread type ClassLoader
this.contextClassLoader parent.getContextClassLoader = ();
// set ClassLoader member variable
this.inheritedAccessControlContext = AccessController.getContext (); // set access permissions control environment
IF (parent.inheritableThreadLocals! = null) {
// create objects to the current thread ThreadLocalMap, and inherit the data ThreadLocalMap parent in
// create thread instance ThreadLoacaleMap. We need to use parent thread ThreadLocaleMap, the purpose of the variable copy of a copy of the parent thread in the current thread.
// ThreadLocaleMap Entry is a type of array, Thread will save a copy of the instance variables in there.
= ThreadLocal.createInheritedMap this.inheritableThreadLocals (
parent.inheritableThreadLocals);
}
}
. 1
2
. 3
. 4
. 5
. 6
. 7
. 8
. 9
10
. 11
12 is
13 is
14
15
16
. 17
18 is
. 19
20 is
21 is
22 is
23 is
24
25
26 is
27
28
29
30
31 is
32
33 is
34 is
35
36
37 [
38 is
39
here Thread completion of the initialization.
----------------

Guess you like

Origin www.cnblogs.com/liyanyan665/p/11402909.html