On Saturday, March 30, 2019 at 6:28:45 AM UTC+1, Shai Almog wrote: > > Because the constructor happens on a separate thread. >
Sorry but I am afraid I don't get you here. What do you mean by "the constructor happens on a separate thread"? Are you talking about the Wrapper (=ThreadSafeDatabase) constructor or the Database one? The ThreadSafeDatabase class is just a wrapper that declare an easythread and the targeted database in its constructor so it looks like it is performing exactly as you suggested to do (it is a wrapper class that does the SQL operations on the db by passing them to it's easythread). Is the issue the fact that the "Database" object should also be created through the easythread thread? (so the call to the Display.getInstance(). openOrCreate() should be called from a runnable passed to the easythread wrapper instead of beeing directly passed as an already created "Database" object passed as argument of the ThreadSafeDatabase constructor). If so, why not modify the ThreadSafeDatabase class to be created with an empty private constructor that only create the easythread and then have a ThreadSafeDatabase.openOrCreate(String dbfile) static constructor function that return a working ThreadSafeDatabase object by creating a ThreadSafeDatabase and calling the Display.getInstance().openOrCreate( dbfile) through its easythread to create the database? It would be better than having a ThreadSafeDatabase class that is tagged as deprecated because not working properly (meaning it is useless and pollute the API for nothing) In any case, could you give a simple example of how the wrapper you suggest should be created (an example with the database creation and 2 SQLite calls (possibly comming from 2 different threads), so we can easilly see in which thread exactly each of these operations are supposed to happen)? Thanks -- You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group. To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discussions+unsubscr...@googlegroups.com. Visit this group at https://groups.google.com/group/codenameone-discussions. To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/e21ccc1e-e06e-4f5b-99dd-fe6a7f9c3ac4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.