Java basic static keywords

Source: Internet
Author: User

WriteProgramThere is a strange phenomenon in a data processing module. There is a variable in it that is a writable list, which is modified with protected. Data is appended in the thread, and then processed data is retrieved externally, check whether data has been read before. The structure is as follows:

// The global variable stores the data protected into list <bitmap> outer_q = new into list <bitmap> (); run {While (true ){... // generate bitmapouter_q.add (Bitmap); system. out. println ("Run () ----> outer_q.size =" + outer_q.size () ;}} public Boolean isgetdata () {system. out. println ("isgetdata () ----> outer_q.size =" + outer_q.size (); Return outer_q.size () = 0? False: true ;}

Then the strange phenomenon occurs. After each add operation, the calculation size is increased every time. When isgetdata () is used to calculate the size, 0 is returned for both life and death, which is strange. Somehow, the logical relationship is handled n times and thoroughly checked. There is no place to remove the content of the linked list. It's a strange thing. Nima was finally defined to add the static keyword to modify and erase it. The whole world is bright. Nima, this road kill cannot afford to hurt java. It is such a tragedy if the foundation is not good, I have to make up for it... Why... Who gave analysis and why ???

Protected static comment list <bitmap> m_out_q = new comment list <bitmap> ();

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.