Eric Wilson
Eric Wilson

Reputation: 59405

Do I need to synchronize if I have multiple threads that will insert to MySQL?

I'll be using a multi-threaded Java program to insert new records to a table in MySQL. Is it necessary to synchronize for this? Or is it OK since each insert is a different record in my case?

Upvotes: 2

Views: 781

Answers (1)

oxbow_lakes
oxbow_lakes

Reputation: 134330

The database driver will do this for you under the covers, if it is necessary. You should assume that the database can handle concurrent CRUD access.

The drivers I've used for SQLServer and Sybase have always locked the Connection object, although you could be using multiple connections via a pool of course!

Upvotes: 6

Related Questions