Search code examples
androiddelphifiremonkey

Is it safe to fetch data using multi threading?


I am new to multi-threading.

  • I have a database with 8 tables on the server.
  • I connect to the database directly using an Android device.
  • I want to get data from the server and insert it into a client database (SQLite).
  • I have a function that inserts all of the data from the server into the client, and I call that function for every table.

Is it safe to make 8 threads, one for every table? I use TTask.


Solution

  • Theoretically it should be safe, assuming each table is accessed using a separate thread and no data is shared between the threads.

    It should be safe even if you slightly "mess up", since the databases are likely to be thread safe.

    However, your internal code might not be thread safe, so we don't really know.