I am developing a multi threaded application, that uses both threads and Async tasks to execute code on multiple threads.
I have an AsyncTask that adds a row to a database, and then sends off an API request. Once the API request reply is received, it updates the row in the database. The database adapter object is passed to the AsyncTask from the UI thread.
Unfortunately, the AsyncTask doesn't work on multi core devices (such as the Asus Transformer). A null pointer exception occurs when I try to add the row to the database for the first time.
I don't know why this happens, but it may be something to do with what is says in the docs under 'Memory Observability'.
Thanks for the comments guys.
It turns out I did have a race condition. I didn't realise that onActivityResult was called before onResume, and so it turned out that on slower phones, the runnable task would be executed after onResume was called (and so the database had been opened), but on faster phones, the runnable task would get to the database operation first and be met with a NPE.
Thanks!