Android determines whether the current thread is UI thread

Source: Internet
Author: User
<span id="Label3"><p>In android, determine whether the current thread is the UI Thread's method:</p><p>1.</p><pre><span style="color: #0000ff;">if</span> (looper.mylooper () = =<span style="color: #000000;"> Looper.getmainlooper ()) {</span><span style="color: #008000;">//</span> Current thread is the<span style="color: #008000;"> ui/main thread</span> c6>} </pre><p>2.</p><pre><span style="color: #0000ff;">if</span> (looper.getmainlooper (). getthread () = =<span style="color: #000000;"> Thread.CurrentThread ()) {</span><span style="color: #008000;">//</span> current<span style="color: #008000;"> Thread is The Ui/main thread</span>}</pre><p></p><p>Refer to the following article: the use of the Runonuithread () method is also Mentioned.</p><p>Http://codetheory.in/checkdetect-whether-current-thread-uimain-thread-android/</p><p>Http://lak4cyut.blogspot.jp/2011/03/android-tip-activityrunonuithread.html</p><p>Android determines whether the current thread is UI thread</p></span>

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.