SQLiteCursor和ContentProvider的线程安全问题
来源:互联网 发布:vnpy 知乎 编辑:程序博客网 时间:2024/05/17 21:48
1、SQLiteCursor is not internally sychronize so code using a SQLiteCursor from multiple threads should perfor its own synchronization when using the SQLiteCursor.
2、http://developer.android.com/guide/components/processes-and-threads.html#Threads
In some situations, the methods you implement might be called from more than one thread, and therefore must be written to be thread-safe.
This is primarily true for methods that can be called remotely—such as methods in a bound service. When a call on a method implemented in an IBinder
originates in the same process in which the IBinder
is running, the method is executed in the caller's thread. However, when the call originates in another process, the method is executed in a thread chosen from a pool of threads that the system maintains in the same process as theIBinder
(it's not executed in the UI thread of the process). For example, whereas a service's onBind()
method would be called from the UI thread of the service's process, methods implemented in the object thatonBind()
returns (for example, a subclass that implements RPC methods) would be called from threads in the pool. Because a service can have more than one client, more than one pool thread can engage the sameIBinder
method at the same time. IBinder
methods must, therefore, be implemented to be thread-safe.
Similarly, a content provider can receive data requests that originate in other processes. Although theContentResolver
and ContentProvider
classes hide the details of how the interprocess communication is managed, ContentProvider
methods that respond to those requests—the methods query()
, insert()
,delete()
, update()
, and getType()
—are called from a pool of threads in the content provider's process, not the UI thread for the process. Because these methods might be called from any number of threads at the same time, they too must be implemented to be thread-safe.
- SQLiteCursor和ContentProvider的线程安全问题
- Servlet和JSP的线程安全问题
- Servlet和JSP的线程安全问题 [转载]
- Servlet和JSP的线程安全问题
- Servlet和JSP的线程安全问题
- Servlet和JSP的线程安全问题
- Servlet和JSP的线程安全问题
- Servlet和Action的线程安全问题
- Struts1和Struts2的Action线程安全问题
- Struts1和Struts2的Action线程安全问题
- Servlet和JSP的线程安全问题
- servlet、struts1和struts2的线程安全问题
- Servlet和JSP的线程安全问题
- 属性和变量的线程安全问题
- Struts1和Struts2的Action线程安全问题
- 线程安全问题出现的原因和解决方法
- 线程的开启和解决安全问题
- hashMap非线程安全问题和concurrenthashmap线程安全的比较
- Leetcode#16||3 Sum Closest
- Java安全通信概述
- LeetCode题解:Implement Stack using Queues
- Andriod 内存泄露问题的整理
- C++常见错误及解决方法
- SQLiteCursor和ContentProvider的线程安全问题
- Universal-Image-Loader.jar
- Service基础概念了解
- poj3258 二分最小值最大化
- HDU 1257 最少拦截系统
- 机房收费之细节优化
- 【linq学习笔记】1、linq to xml
- [LeetCode.Trick]Largest Number
- R的一些基本操作