SQLite Forum

Internal schema cache not refreshed after DROP TABLE in different connection
You must check the return status of EACH and EVERY call to SQLite to be sure that what you purport to be doing is actually happening.

Depending on sleep() to "synchronize" your threads is not safe (it assumes that the called function complete in negligible time, which may not be the case when one writer is blocked by the other writer) and the order of output on stdout may be affected by buffering.

Also, you neglected to call sqlite3_step() on the SELECT FROM sqlite_master.