publicclassTest{ publicstaticvoidmain(String[] args)throws InterruptedException { f(); } publicstaticvoidf()throws InterruptedException { for(int i = 0; i < 10000; i++) { new Timer(true); Thread.sleep(1000); } } }
打一个threaddump,没法发现f与新线程的关系。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
"Timer-31" daemon prio=5 tid=0x00007fc74a894800 nid=0x6407 in Object.wait() [0x00007000017db000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000007d596be10> (a java.util.TaskQueue) at java.lang.Object.wait(Object.java:503) at java.util.TimerThread.mainLoop(Timer.java:526) - locked <0x00000007d596be10> (a java.util.TaskQueue) at java.util.TimerThread.run(Timer.java:505)
Locked ownable synchronizers: - None "main" prio=5 tid=0x00007fc74a80b000 nid=0x1703 waiting on condition [0x0000700000219000] java.lang.Thread.State: TIMED_WAITING (sleeping) at java.lang.Thread.sleep(Native Method) at test.Test.f(Test.java:13) at test.Test.main(Test.java:8)
wiki https://alibaba.github.io/arthas tutorials https://alibaba.github.io/arthas/arthas-tutorials version 3.1.1 pid 22316 time 2019-08-02 17:43:18
$
然后用stack命令查看Thread.start的调用堆栈。
1 2 3 4 5 6
$ stack java.lang.Thread start No class or method is affected, try: 1. sm CLASS_NAME METHOD_NAME to make sure the method you are tracing actually exists (it might be in your parent class). 2. reset CLASS_NAME and try again, your method body might be too large. 3. check arthas log: /home/weblogic/logs/arthas/arthas.log 4. visit https://github.com/alibaba/arthas/issues/47 for more details.
$stack java.lang.Thread start ..... ts=2019-08-02 18:13:11;thread_name=[ACTIVE] ExecuteThread: '17' for queue: 'weblogic.kernel.Default (self-tuning)';id=2e;is_daemon=true;priority=5;TCCL=weblogic.utils.classloaders.ChangeAwareClassLoader@40d0d36f @java.util.Timer.<init>() at java.util.Timer.<init>(Timer.java:146) at com.ibm.db2.jcc.am.io.a(io.java:4953) at com.ibm.db2.jcc.am.io.Zb(io.java:5019) at com.ibm.db2.jcc.am.jo.b(jo.java:4058) at com.ibm.db2.jcc.am.jo.hc(jo.java:2732) at com.ibm.db2.jcc.am.jo.execute(jo.java:2715) at weblogic.jdbc.wrapper.PreparedStatement.execute(PreparedStatement.java:105) at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:57) at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:70) at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:57) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:141) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:98) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:73) at org.apache.ibatis.executor.keygen.SelectKeyGenerator.processGeneratedKeys(SelectKeyGenerator.java:65) at org.apache.ibatis.executor.keygen.SelectKeyGenerator.processBefore(SelectKeyGenerator.java:41) at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:80) at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:58) at org.apache.ibatis.executor.BatchExecutor.doUpdate(BatchExecutor.java:68) at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108) ......
IBM Data Server driver for JDBC and SQLJ(JCC) has both db2jcc.jar and db2jcc4.jar. What is the difference between those 2 files, db2jcc.jar and db2jcc4.jar?
Answer
Both of them are DB2 JDBC driver jar files and are Type 4 drivers.
db2jcc.jar includes functions in the JDBC 3.0 and earlier specifications. If you plan to use those functions, include the db2jcc.jar in the application CLASSPATH.
db2jcc4.jar includes functions in JDBC 4.0 and later, as well as JDBC 3.0 and earlier specifications. If you plan to use those functions, include the db2jcc4.jar in the application CLASSPATH.
timerLevelForQueryTimeout can be disabled by setting it to a value
of -1 (com.ibm.db2.jcc.DB2BaseDataSource.QUERYTIMEOUT_DISABLED)
The property “timerLevelForQueryTimeout” is used to indicate the
driver if it needs to create a timer object for each statement
execution or one per connection common to all statements created
under that connection. If this property is set to QUERYTIMEOUT_STATEMENT_LEVEL then the timer object is created before every execution of the statement and then destroyed after the execution.
Where the value QUERYTIMEOUT_CONNECTION_LEVEL creates one timer object per
connection and all the statement created on that connection share
that timer object for their executions. When you have lot of
statements on a connection it is better to use a common timer on a
connection otherwise it will end up creating lot of timer object and
can cause out of memory. This property can also be set like any
other property either on the datasource or in a URL.