The IBM WebSphere application server, respectively, is running on the IBM JVM. The application works in several threads, both WebContainer and background processes. In a separate thread, I get all the threads that are running in this JVM, thus:
Set<Thread> threadSet = Thread.getAllStackTraces().keySet(); for(Thread t: threadSet){ ... }
Is it possible to somehow get a list of all objects, for example, the class java.sql.Connection, or its successors, and execute some query to the database on their behalf.
For example, several threads have their connections to the database and I need to know which SQL_ID is used by each thread.
Is it possible to implement it? Maybe there is another way to solve this problem?
ThreadLocal
? Still, in the general case, instances of classes and threads that call methods on them are orthogonal to each other and do not consist in a has-a relationship. - Nofate ♦