have the ability, must read, read notes, see the Truth
Import Sun.misc.Unsafe;
Import Java.io.FileInputStream;
Import Java.lang.reflect.Field;
Import java.util.*;
Import java.util.concurrent.*;
Import Java.util.concurrent.atomic.AtomicInteger;
Import Java.util.concurrent.atomic.LongAdder;
Import Java.util.concurrent.locks.ReentrantLock;
Import Java.util.concurrent.locks.ReentrantReadWriteLock;
/** * These classes of source code must look at * Created by cherish on 2017/3/10.
* * Public class Needtoread {public static void main (string[] args) {string = "The original integer literal is compiled like this," +
"Call the Integer.valueof (i), you can take the cache";
Boolean bool = true;
Byte B = 1;
Character Character = ' C ';
Short Shorti = 64;
Integer integer = 127;
Long L = 127L;
Float f = 0.0F;
Double d = 0.0;
Class clazz = Class.class;
StringBuilder StringBuilder = new StringBuilder (16); StringBuffer StringBuffer = new StringBuffer//Tostringcache cache thread thread with tostring = new ThRead ();
ThreadLocal ThreadLocal = new ThreadLocal ();
Threadlocalrandom random = Threadlocalrandom.current ();
TODO Each treadlocal is just a key, it corresponds to. set (value);
TODO uses it itself as a key to get value Threadlocal.set (random) in Threadlocalmap;
Object o = Threadlocal.get ();
System.out.println ("o =" + O.getclass ());
ThreadLocal threadLocal2 = new ThreadLocal ();
Threadlocal2.set (threadLocal);
Object O1 = Threadlocal2.get ();
System.out.println ("o1.getclass () =" + O1.getclass ());
TODO data source//todo java.util and concurrent packets, read the source code TreeMap Rbtree = new TreeMap () carefully;
HashMap HashMap = new HashMap (8);
Iterator iterator = Hashmap.entryset (). iterator ();
ArrayList ArrayList = new ArrayList ();
LinkedList LinkedList = new LinkedList ();
Abstractqueue priorityqueue = new Priorityqueue ();
Blockingqueue lbqueue = new Linkedblockingqueue (); Concurrentmap CoNcurrentmap = new Concurrenthashmap ();
Copyonwritearraylist copyonwritearraylist = new Copyonwritearraylist ();
Atomicinteger Atomicinteger = new Atomicinteger ();
Longadder Longadder = new Longadder ();
Reentrantlock lock = new Reentrantlock ();
Reentrantreadwritelock Readwritelock = new Reentrantreadwritelock ();
Executorservice Executorservice = Executors.newfixedthreadpool (5);
Forkjoinpool forkjoin = new Forkjoinpool (); Executorservice threadpoolexecutor = new Threadpoolexecutor (5, 5, timeunit.sec
Onds, New linkedblockingqueue<> ());
Futuretask futuretask = new Futuretask<> (()-> new Random (). Nextint (100));
Final String returnobj = "";
Futuretask = new Futuretask<> (()-> {}, returnobj); completablefuture<string> completablefuture = Completablefuture.supplyasync (()-> {return "Hello Com PletableFuture! ";});
Completablefuture future = completablefuture.thenaccept (O2-> {System.out.println) ("thenaccept:" + O2);
});
FileInputStream fileinputstream;//policy mode, decorator mode Field theunsafe = null;
try {theunsafe = Unsafe.class.getDeclaredField ("Theunsafe");
Theunsafe.setaccessible (TRUE);
Final Unsafe Unsafe = (Unsafe) theunsafe.get (null);
System.out.println (UNSAFE); catch (Nosuchfieldexception |
Illegalaccessexception e) {e.printstacktrace (); }
}
}