工作时,一直对try块中throw的异常对象,在catch中如何处理此异常,以及trycatchfinally完毕,程序是否就此停止还是继续运行很迷惑,于是参考网上的资料,自己写了些demo,去慢慢探索. 例1. public static void main(String[] args) { int i = 7; int j = 0; try { if (j == 0) throw new ArithmeticException(); System.out.println("打印计算结果i/j
SQL Server Try Catch 异常捕捉 背景 今天遇到一个关于try catch 使用比较有意思的问题.如下一段代码: SELECT @@TRANCOUNT AS A BEGIN TRY BEGIN TRAN SELECT @@TRANCOUNT AS A1 INSERT INTO A2A ( ID1 ) VALUES ( 'A' ) COMMIT TRAN; END TRY BEGIN CATCH SELECT @@TRANCOUNT AS A2 ROLLBACK TRAN; SE
等待多个子线程结束后再执行主线程 class MultiThread{ #region join test public void MultiThreadTest() { Thread[] ths = new Thread[2]; ths[0] = new Thread(Method1); ths[1] = new Thread(Method2); foreach (Thread item in ths) { //首先让所有线程都启动 item.Start(); //试想一下在这里加上item.