multithreading - Android: How to determine on which threads are my methods are running? -


I would like to ensure that my methods are running on threads, for which I wanted to run, threads in my logs I want to add name or id to check whether my methods are running in UIthread, thread1, thread2 .... threadx.

Problem:

  1. To determine what I have to do, the name of the thread or ID is not certain about this, if you have a better viewpoint Please share to us how to differentiate UI threads from other additional running threads.
  2. I want to know the method of calling above to get the name or id already, the thread name () or thread.id ().

    Any guidance is appreciated. Use

    In fact, you really need an example in docs:

      Import java.util.concurrent.atomic.AtomicInteger; Public category UniqueThreadIdGenerator {Personal Static Ultimate AtomicInteger uniqueId = New AtomicInteger (0); Private stable last throcalal & lt; Integer & gt; Exclusive New = New Thread Local & lt; Integer & gt; () {@ Override protected integer initial value () {unique iod and return (); }}; Public static int getCurrentThreadId () {return uniqueId.get (); }} // UniqueThreadIdGenerator   

    If you want, you can pass the desired name to the thread and it will be in the first row in the run ThreadLocal Can set in Variable () Method.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -