Hi Jens,

Thank you for the response.  
I left it at default so it should be a 1.  The threads are not I/O.  They each 
execute only a few short lines of code to gather network information and then 
hit the DB for a read using the information they just gathered to populate a 
key.  After the read they add the formatted data to a table that is eventually 
displayed to the user.

A quick overview of the code.
I check 64K ports for a response to determine if they are open or not (Nothing 
nefarious).  I use 30+ threads because it could take up to 10 seconds for a 
port to respond while other ports respond immediately.

If you are curious to see the app in action and get a better picture of what 
I'm doing.  It's on the Microsoft store for free.

Do a search of the MS Store for an App named Lo and Behold.

Or click this link..

https://www.microsoft.com/en-us/store/p/lo-and-behold/9nblggh533kc

-Ron

-----Original Message-----
From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On 
Behalf Of Jens Alfke
Sent: Thursday, January 4, 2018 8:03 PM
To: SQLite mailing list <sqlite-users@mailinglists.sqlite.org>
Subject: Re: [sqlite] new Error database disk image is malformed



> On Jan 4, 2018, at 4:51 PM, Ron Barnes <rbar...@njdevils.net> wrote:
> 
> I hope not since I use synclock in my code when ever a thread is attempting a 
> write to the database.  That seems like the only issue from that page that I 
> may be doing.  I could have up to 30 or more threads reading from the DB but 
> only one to three active threads writing.

It depends on the value of SQLITE_THREADSAFE that SQLite was compiled with. 
(Check the docs for details.) If it’s set to 1, you can do what you’re doing. 
Otherwise, you cannot use a single SQLite connection on multiple threads 
without using your own mutex (if it’s 2), or at all (if it’s 0).

30 threads sounds like overkill, BTW. Generally the appropriate number is equal 
to the number of CPU cores. And if the task is I/O-bound there’s not much 
benefit to having more than one since only one of them can be inside SQLite at 
a time.

—Jens
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to