1 package com.example.simpleperf.simpleperfexamplepurejava; 2 3 import android.support.v7.app.AppCompatActivity; 4 import android.os.Bundle; 5 6 public class MainActivity extends AppCompatActivity { 7 8 @Override onCreate(Bundle savedInstanceState)9 protected void onCreate(Bundle savedInstanceState) { 10 super.onCreate(savedInstanceState); 11 setContentView(R.layout.activity_main); 12 13 createBusyThread(); 14 } 15 createBusyThread()16 void createBusyThread() { 17 new Thread(new Runnable() { 18 volatile int i = 0; 19 20 @Override 21 public void run() { 22 while (true) { 23 i = callFunction(i); 24 } 25 } 26 27 private int callFunction(int a) { 28 return a+1; 29 } 30 }, "BusyThread").start(); 31 } 32 } 33