Android 开发基础 Threads
2010-07-15 21:19:00 来源:WEB开发网即使你可以限制您的程序在一个单独的进程里,但总有需要产生一个线程来做一些后台工作的时候。由于用户界面必须及时相应用户的操作,含有一个activity的线程最好不要同时含有一个资源占用比较大运算,比如下载。任何不会很快结束的运算都应该放在不同的线程里。
线程是用标准java线程对象在代码中创建的。android提供了一些方便的类来管理线程:在一个线程中运行消息循环的Looper,处理消息的Handler,建立一个带有loop循环的线程的HandlerThread。
原文
Threads
Even though you may confine your application to a single process, there will likely be times when you will need to spawn a thread to do some background work. Since the user interface must always be quick to respond to user actions, the thread that hosts an activity should not also host time-consuming operations like network downloads. Anything that may not be completed quickly should be assigned to a different thread.
Threads are created in code using standard Java Thread objects. Android provides a number of convenience classes for managing threads — Looper for running a message loop within a thread, Handler for processing messages, and HandlerThread for setting up a thread with a message loop.
- ››Android 当修改一些代码时,使用什么编译命令可以最...
- ››Android 如何添加一个apk使模拟器和真机都编译进去...
- ››Android 修改Camera拍照的默认保存路径
- ››Android 如何修改默认输入法
- ››android开发中finish()和System.exit(0)的区别
- ››Android手势识别简单封装类
- ››android中查看项目数字证书的两种方法
- ››Android中获取IMEI码的办法
- ››android 相机报错 setParameters failed
- ››Android重启运用程序的代码
- ››Android为ListView的Item设置不同的布局
- ››android bitmap与base64字符串的互相转换
更多精彩
赞助商链接