Multithreaded and multiple-context applications in DB2 ODBC
DB2® ODBC supports
multi-threading and multiple contexts. You need to follow certain
guidelines when using multiple contexts and multi-threading together
in an application.
DB2 ODBC support for multiple Language Environment threads
A Language
Environment® thread represents an independent instance of a routine
within an application. When you execute a DB2 ODBC application, it begins with an initial Language Environment thread,
or parent thread.
When to use multiple Language Environment threads
Some general application types are well-suited to multithreading.
For example, applications that handle asynchronous work requests make
good candidates for multithreading.
DB2 ODBC support of multiple contexts
A context is the DB2 ODBC equivalent of a DB2 thread. Contexts are the structures that
describe the logical connections that an application makes to data
sources and the internal DB2 ODBC
connection information that allows applications to direct operations
to a data source.
External contexts
Typically, the DB2 ODBC
driver manages contexts in an ODBC application. With external contexts,
you can write applications that manage contexts outside of DB2 ODBC. You use external contexts
in combination with Language
Environment threads in the same way you use multiple contexts
in combination with Language
Environment threads.
Application deadlocks
When you use multiple connections to access the same database
resources concurrently, you create general contention for database
resources. Timeouts and deadlocks can result from this contention.