Skip to content

Instantly share code, notes, and snippets.

@Dcosta2205
Last active November 2, 2020 09:38
Show Gist options
  • Save Dcosta2205/d24595bbabbc51cd2d82cd048fa0fd4a to your computer and use it in GitHub Desktop.
Save Dcosta2205/d24595bbabbc51cd2d82cd048fa0fd4a to your computer and use it in GitHub Desktop.
public class MainActivity extends AppCompatActivity {
private Runnable runnable = new Runnable() {
@Override
public void run() {
// This runs in background thread. Do heavy operations here
}
// This thread will die once it comes out of the run method
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Thread thread = new Thread(runnable);
thread.start();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment