2
In my app there are some threads that access the database and control this competition using the totalcross Lock.
My question is: Can I allow exceptions to be thrown into a Synchronized block ? or have to do something so that the exception is thrown out of its scope ?
Today I keep this from happening.
Follow an example of code used:
public int executeUpdate(int dbIdx, String sql) {
int res = 0;
// secure access for database resource
synchronized (MainDB.lockDB) {
try {
Debug.debug(sql, Debug.DEBUG_LEVEL_DEBUG);
// Create statement to execute query
Statement st = connPool[dbIdx].createStatement();
// Execute query
res = st.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return res;
}
Launch or treat/capture?
– ramaral
Whatever. The purpose of the question was to understand how Totalcross behaves when the execution flow is stopped before the end of the Synchronized scope, to understand whether the lock is released or not.
– Bruno Silva