Java must-read source code __java

Source: Internet
Author: User
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 (); }


    }
}

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.