Thread Safe

The Android UI toolkit is not thread-safe and must always be manipulated on the UI thread.

What is thread safe?
In computer programming, thread-safe describes a program portion or routine that can be called from multiple programming threads without unwanted interaction between the threads

In other words, you can’t deal with any widgets or UI components in other thread unless the main thread, because the widgets are not prepared to be called from multiple thread, they are not thread safe.

Android offers several ways to access the UI thread from other threads:

  • Activity.runOnUiThread(Runnable)
  • View.postDelayed(Runnable, long)

For more complex codes, Android 1.5 offers a new utility class, called AsyncTask.

Deixe um comentário

Preencha os seus dados abaixo ou clique em um ícone para log in:

Logo do

Você está comentando utilizando sua conta Sair /  Alterar )

Foto do Facebook

Você está comentando utilizando sua conta Facebook. Sair /  Alterar )

Conectando a %s