Refactor worker thread into separate class

This moves the logic for the worker thread into a separate class and moves
the logic for stopping and cleaning up threads into a private AsyncTask in
the MainActivity.