机器人可以SQLiteDatabase的单一实例管理多个线程之间的同步? [英] android can single instance of SQLiteDatabase manage synchronization between multiple threads?

查看:159
本文介绍了机器人可以SQLiteDatabase的单一实例管理多个线程之间的同步?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要做写入不同的AsyncTask线程数据库但问题是,我们需要确保在同一时间只有一个线程应该是写入数据库的过程?我的问题是,如果我使用使得SQLiteDatabase的单一实例对象遍及应用,将是单实例管理不同的线程或不之间的同步Singleton模式?
谢谢


解决方案

  

我的问题是,如果我在做SQLiteDatabase对象的单个实例上的所有应用程序中使用Singleton模式,将是单实例管理不同的线程或不之间的同步?


是的,它会的。

I need to do writing into the database from different AsyncTask threads but the problem is that we need to be sure that at one time only one thread should be in the process of writing into the db? My question is if i use the singleton pattern in making the single instance of SQLiteDatabase object all over the application,will that single instance manage the synchronization between different threads or not ? Thanks

解决方案

My question is if i use the singleton pattern in making the single instance of SQLiteDatabase object all over the application,will that single instance manage the synchronization between different threads or not ?

Yes, it will.

这篇关于机器人可以SQLiteDatabase的单一实例管理多个线程之间的同步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆