简体   繁体   English

如何在特定线程上运行我的代码?

[英]How to run my code on the specific thread?

How to run my code on the specific thread? 如何在特定线程上运行我的代码?

If "the specific thread" is main ui Thread, I can do use runOnUiThread method. 如果“特定线程”是主ui线程,我可以使用runOnUiThread方法。

But "the specific thread" is not ui Thread and "the specific thread" is not made by me. 但“特定线程”不是ui线程,而“特定线程”不是由我制作的。

"the specific thread" is made by some library. “特定线程”由某些库创建。

But I can access "the specific thread". 但我可以访问“特定线程”。

Like this, Thread theSpecificThread = getThread(); 像这样, Thread theSpecificThread = getThread();

How to run my code on the specific thread like runOnUiThread(new Runnable())? 如何在特定的线程上运行我的代码,如runOnUiThread(new Runnable())?

You have to arrange for the thread to call it. 你必须安排线程来调用它。 If this thread is buried in an opaque library, doesn't call any accessible methods or events and provides no way of signaling it to do something you can get at, then I'm afraid that you have a big problem. 如果这个线程被隐藏在一个不透明的库中,不会调用任何可访问的方法或事件,也没有办法发出信号让它做你可以得到的东西,那么我担心你有一个大问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM