Sync issues between Android threads

Source: Internet
Author: User

I now have 2 Android threads, one is the view thread, one is the worker thread, and I now want the project thread to pause until the view thread's OnDraw method is called before continuing to run

How to do? How to wait for a signal

Processing methods


To pass an object in a java2 thread, let one thread notify the other thread as follows, calling in the worker thread
Stick.wait ();
When the view thread finishes its onDraw work, it calls this:
You can call Stick.notify () when the view thread finishes calling OnDraw.
Stick.notify ();

Note that the view thread has the requirements for the display on that object. For you, this should be fairly simple to execute with a small sync block:

123456 void ondraw () {   ...    synchronized (stick) {     stick.notify ();    } } // end onDraw()



Original address: http://www.itmmd.com/201411/97.html
This article by Meng Meng's IT person to organize the release, reprint must indicate the source.

Sync issues between Android threads

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.