I wrote this code to try threads on Android, but it doesn\'t work.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(save
You're calling t.run()
which means you're running all the code in the UI thread without starting a new thread.
You should call t.start()
which will instead start a new thread and execute the code in the run
method within that new thread.
(I'd also recommend implementing Runnable
and then passing the Runnable
to a new Thread
constructor rather than overriding run
, just as a matter of separation of concerns. It won't change the behaviour here, but it's a cleaner way of thinking about it IMO.)