0

I was reading multi-threading priority queue here. In this I don't understand why workQueue is passed as parameter to the self method in class myThread we could have directly used workQueue instead of using self.q. So I wrote without it worked but then I tried to do the same for connecting to database.I opened a common DB connection and allowed every thread to use it. But it did not work , ( my update was not reflected in database). I thought that as threads were pre-emptying it was not possible for them to maintain a connection to execute the query. But then I gave every thread a DB connection which I initially passed to the self method.

Basically, I implemented this. And to my surprise this worked. How is it different from what I was doing?

4

2 に答える 2