There is synchronization with the server. Runs a couple of threads that request data and write each to their own table using transactions. Is it possible to ensure the synchronization of all synchronization using internal transactions or in another way?
A simple example :
new AsyncTask<Void,Void,Void>(){ @Override protected void onPreExecute() { super.onPreExecute(); db.beginTransactionNonExclusive(); } @Override protected Void doInBackground(Void... params) { db.beginTransactionNonExclusive(); try { ... db.setTransactionSuccessful(); } finally { db.endTransaction(); } return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); db.setTransactionSuccessful(); db.endTransaction(); } }.execute();
Bd is locked and on the second db.beginTransactionNonExclusive()
(if there is no transaction, then on data insertion) the flow stops. Connect to the base of one. yieldIfContendedSafely()
seems to be helping, but it returns false.