ODBC 多线程并行执行SQLExecute
每个线程创建一个连接,然后执行 SQLExecute,但是会阻塞在SQLExecute。
比如我单线程执行SQLExecute需要1秒
开两个线程执行SQLExecute,那线程1执行1s,线程2由于开始稍微晚一些,SQLExecute执行时间为等待线程1的1秒加上自己的1秒,总共2秒。
如果多线程循环执行SQLExecute,每次都被阻塞,并没有起到多线程提高效率的目的。
查看MSDN 的 ODBC API
SQLExecute executes a statement prepared by SQLPrepare. After the application processes or discards the results from a call to SQLExecute, the application can call SQLExecute again with new parameter values.
附上链接:
https://msdn.microsoft.com/en-us/library/ms713584(v=vs.85).aspx#Comments
是说一个应用程序在SQLExecute返回后,才能执行新的SQLExecute函数。
有没有办法多线程并行执行SQLExecute函数?