From 4d367dfb82e02619241ca5550bfd1768bb6504c3 Mon Sep 17 00:00:00 2001 From: Guo Yang <352391291@qq.com> Date: Tue, 7 Feb 2017 11:36:58 +0800 Subject: [PATCH] Update README.md --- README.md | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d426efa..2ec2c5a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,51 @@ #RxUtilDemo -//使用内部封装的线程池进行耗时任务Toast.makeText(this, "IO线程进行耗时操作,请在控制台查看Log", Toast.LENGTH_SHORT).show();String str = "模拟IO线程执行耗时操作";RxjavaUtil.doInIOThread(new IOTask(str) { @Override public void doInIOThread() { for (int i = 0; i < 5; i++) { try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } Log.v("test", getT()); } }}); + //使用内部封装的线程池进行耗时任务 + Toast.makeText(this, "IO线程进行耗时操作,请在控制台查看Log", Toast.LENGTH_SHORT).show(); + String str = "模拟IO线程执行耗时操作"; + RxjavaUtil.doInIOThread(new IOTask(str) { + @Override + public void doInIOThread() { + for (int i = 0; i < 5; i++) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + Log.v("test", getT()); + } + } + }); + + //在子线程中修改UI + new Thread(new Runnable() { + @Override + public void run() { + String str2 = "子线程中修改UI"; + RxjavaUtil.doInUIThread(new UITask(str2) { + @Override + public void doInUIThread() { + tv_test.setText(getT()); + } + }); + } + }).start(); + + //在IO线程进行耗时操作 执行完成后修改UI + String str3 = "耗时操作结束修改UI"; + Toast.makeText(this, "请等候三秒再看测试的文本框内容变化", Toast.LENGTH_SHORT).show(); + RxjavaUtil.executeRxTask(new CommonRxTask(str3) { + @Override + public void doInIOThread() { + try { + Thread.sleep(3000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + setT(getT() + "--------小尾巴"); + } + + @Override + public void doInUIThread() { + tv_test.setText(getT()); + } + });