很抱歉,您没有提供需要重构的内容。请提供具体的文本或段落,我将为您重新组织和优化。
以下是重构后的代码:
```java
public class MainActivity extends AppCompatActivity {
private HandlerThread handlerThread;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
handlerThread = new HandlerThread("子线程");
handlerThread.start();
Looper looper = handlerThread.getLooper();
final Handler handler = new Handler(looper) {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
Log.d("-----", "线程:" + Thread.currentThread().getName());
}
};
findViewById(R.id.bt).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
handler.sendEmptyMessage(100);
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
handlerThread.quit();
}
}
```