File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
library/src/com/lidroid/xutils Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 31
31
import java .util .HashMap ;
32
32
import java .util .List ;
33
33
import java .util .concurrent .ConcurrentHashMap ;
34
+ import java .util .concurrent .locks .Lock ;
35
+ import java .util .concurrent .locks .ReentrantLock ;
34
36
35
37
public class DbUtils {
36
38
@@ -801,9 +803,15 @@ private void debugSql(String sql) {
801
803
}
802
804
}
803
805
806
+ private Lock writeLock = new ReentrantLock ();
807
+ private volatile boolean writeLocked = false ;
808
+
804
809
private void beginTransaction () {
805
810
if (allowTransaction ) {
806
811
database .beginTransaction ();
812
+ } else {
813
+ writeLock .lock ();
814
+ writeLocked = true ;
807
815
}
808
816
}
809
817
@@ -817,6 +825,10 @@ private void endTransaction() {
817
825
if (allowTransaction ) {
818
826
database .endTransaction ();
819
827
}
828
+ if (writeLocked ) {
829
+ writeLock .unlock ();
830
+ writeLocked = false ;
831
+ }
820
832
}
821
833
822
834
You can’t perform that action at this time.
0 commit comments