名称的的AsyncTask的主题 [英] Name the Thread of an AsyncTask
本文介绍了名称的的AsyncTask的主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能提供一个名称的的AsyncTask的后台线程,如在Java中正常主题:
Is it possible to give a name to an AsyncTask's background thread, as for normal Threads in Java:
Thread(Runnable target, String name)
我见过的AsyncTask,默认的构造函数的code只是在默认情况下提供一个名称
I have seen the code of AsyncTask and the default constructor is just give a name by default
private static final ThreadFactory sThreadFactory = new ThreadFactory() {
private final AtomicInteger mCount = new AtomicInteger(1);
public Thread newThread(Runnable r) {
return new Thread(r, "AsyncTask #" + mCount.getAndIncrement());
}
};
我想这样做,因为当我调试,我想知道这AsyncTask的是一个辅助类访问的方法。
I want to do that, as when I debug I want to know which Asynctask is accessing a method in a helper class.
推荐答案
尝试从里面调用这个doInBackground()
:
Thread.currentThread().setName("some custom name");
这篇关于名称的的AsyncTask的主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文