The unexpected harvest of thought revelation (find your own thinking limits and lift the two-level hands of the tiger skin)

Source: Internet
Author: User

Patrick the original on the CSDN. If other sites reproduced please pay attention to the layout and the source:

Today is still the last one to leave, which would have been encapsulated by the threading Extension feature to sell the tickets. But I would like to include a procedure for counting whether there are missing tickets, but always tangled in my multiple threads have more than one object, I have to wait for all the threads to finish the ability to count, but I can not be in the interface class and thread class to write, then I could only write in the class open to the user, then I have more than one class object who to tune??? How many objects did I write in main before I waited for thread execution to finish???

Because I want to solve the first problem, I want to encapsulate the thread's class to accept the return value of the virtual function called in the thread callback function, just have the return value. I go to the end of the scene whether or not to adjust the statistics missed votes, here my brain and tangled, so I have 10 threads I still want to new10 a wrapper thread of the object, so this is more than 10 objects, who to tune statistics, who can not go, all have to wait for other threads to execute the end AH

Others told me to solve the second problem with a level two pointer ah. Second-level pointers. But before I had an intuitive, very magical thing, he said I wanted to use my current code ability, I went to try, did not think very very easy, is to take one of the * with [] to replace. This is not the same as an array of pointers. Although I haven't used any pointers in arrays. Unexpected harvest. Very large harvest, the next few people will you will be proud of, although not difficult, but I expect them and one hours ago I feared "two-level pointer" of the fear and awe is the same

The second harvest is to solve the first problem, I am so tangled up why. No matter who is going to adjust the statistics missed votes. This is simple, if all threads are finished. So I waited for all the threads to be assigned an object to tune out, and I found this logic in my mind. Just like God has two apples. I want his left hand. The apple of his right hand is a little bit better, like the one I summed up last month about the different quality of the ball, since I found out from that question that my mind had been imprisoned for my thoughts, and it helped me a lot later. It's like there was a time when all the people were limiting the reason why a multi-line thread would return to refund I yelled when I was analyzing a couple of threads going around. I have a new idea. I said I didn't control the switch between several threads of execution. My first thread executes once, and my second thread gets the value of the global variable, and I have been executing on the first thread. Other nuclear execution computer other programs, playing games to listen to music to watch movies. Do not let the second thread execute anyway. Then the first thread is about to sell the full ticket, and my second thread is late again, causing a fallback

I'll eat first, and then I'll share the tiger skin with you. Fox

PanPen120 original, hypothesis suggested. Please leave a message

The unexpected harvest of thought revelation (find your own thinking limits and lift the two-level hands of the tiger skin)

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.