Search Results

Search found 8144 results on 326 pages for 'thread'.

Page 3/326 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • C++ boost thread reusing threads

    - by aaa
    hi. I am trying to accomplish something like this: thread t; // create/initialize thread t.launch(); // launch thread. t.wait(); // wait t.launch(); // relaunch the same thread How to go about implementing something like this using boost threads? in essence, I need persistent relaunch-able thread. Thanks

    Read the article

  • Java: How to make this main thread wait for the new thread to terminate

    - by Jeff Bullard
    I have a java class that creates a process, called child, using ProcessBuilder. The child process generates a lot of output that I am draining on a separate thread to keep the main thread from getting blocked. However, a little later on I need to wait for the output thread to complete/terminate before going on, and I'm not sure how to do that. I think that join() is the usual way to do this but I'm not sure how to do that in this case. Here is the relevant part of the java code. // Capture output from process called child on a separate thread final StringBuffer outtext = new StringBuffer(""); new Thread(new Runnable() { public void run() { InputStream in = null; in = child.getInputStream(); try { if (in != null) { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String line = reader.readLine(); while ((line != null)) { outtext.append(line).append("\n"); ServerFile.appendUserOpTextFile(userName, opname, outfile, line+"\n"); line = reader.readLine(); } } } catch (IOException iox) { throw new RuntimeException(iox); } } }).start(); // Write input to for the child process on this main thread // String intext = ServerFile.readUserOpTextFile(userName, opname, infile); OutputStream out = child.getOutputStream(); try { out.write(intext.getBytes()); out.close(); } catch (IOException iox) { throw new RuntimeException(iox); } // ***HERE IS WHERE I NEED TO WAIT FOR THE THREAD TO FINISH *** // Other code goes here that needs to wait for outtext to get all // of the output from the process // Then, finally, when all the remaining code is finished, I return // the contents of outtext return outtext.toString();

    Read the article

  • c# CF Restart a thread

    - by Ed
    Hi all, Supose you have a form with a button that starts/stops a thread (NOT pausing or interrupting, I really need to stop the thread !) Check out this code: Constructor() { m_TestThread = new Thread(new ThreadStart(ButtonsThread)); m_bStopThread = false; } ButtonClick { // If the thread is not running, start it m_TestThread.Start(); // If the thread is running, stop it m_bStopThread = true; m_TestThread.Join(); } ThreadFunction() { while(!m_bStopThread) { // Do work } } 2 questions (remember CF): - How can I know if the thread is running (I cannot seem to access the m_pThreadState, and I've tried the C++ GetThreadExitCode(), it give false results) ? - Most important question : if I have stopped the thread, I cannot restart it, most probably because the m_TestThread.m_fStarted is still set (and it is private so I cannot access it) ! And thus m_TestThread.Start() generates an exception (StateException). Stopping the thread with an Abort() doesn't solve it. If I put my m_TestThread = null; it works, but then I create a memory leak. The GC doesn't clean up either, even if I wait for xx seconds. Anybody has an idea ? All help highly appreciated ! Grtz E

    Read the article

  • Java Threading Concept Understanding

    - by Nirmal
    Hello All... Recently I have gone through with one simple threading program, which leads me some issues for the related concepts... My sample program code looks like : class NewThread implements Runnable { Thread t; NewThread() { t = new Thread(this, "Demo Thread"); System.out.println("Child thread: " + t); t.start(); // Start the thread } public void run() { try { for (int i = 5; i > 0; i--) { System.out.println("Child Thread: " + i); Thread.sleep(500); } } catch (InterruptedException e) { System.out.println("Child interrupted."); } System.out.println("Exiting child thread."); } } class ThreadDemo { public static void main(String args[]) { new NewThread(); // create a new thread try { for (int i = 5; i > 0; i--) { System.out.println("Main Thread: " + i); Thread.sleep(1000); } } catch (InterruptedException e) { System.out.println("Main thread interrupted."); } System.out.println("Main thread exiting."); } } Now this program giving me the output as follows : Child thread: Thread[Demo Thread,5,main] Main Thread: 5 Child Thread: 5 Child Thread: 4 Main Thread: 4 Child Thread: 3 Child Thread: 2 Main Thread: 3 Child Thread: 1 Exiting child thread. Main Thread: 2 Main Thread: 1 Main thread exiting. So, that's very much clear to me. But as soon as I am replacing the object creation code (calling of a NewThread class constructor) to as follows : NewThread nt = new NewThread(); // create a new thread the output becomes a bit varied like as follows : Child thread: Thread[Demo Thread,5,main] Main Thread: 5 Child Thread: 5 Child Thread: 4 Child Thread: 3 Main Thread: 4 Child Thread: 2 Child Thread: 1 Main Thread: 3 Exiting child thread. Main Thread: 2 Main Thread: 1 Main thread exiting. And some times it's giving me same output in both the cases. So, i am not getting the exact change in both the scenario. I would like to know that you the variation in the output is coming here ? Thanks in advance...

    Read the article

  • Delphi - WndProc() in thread never called

    - by Robert Oschler
    I had code that worked fine when running in the context of the main VCL thread. This code allocated it's own WndProc() in order to handle SendMessage() calls. I am now trying to move it to a background thread because I am concerned that the SendMessage() traffic is affecting the main VCL thread adversely. So I created a worker thread with the sole purpose of allocating the WndProc() in its thread Execute() method to ensure that the WndProc() existed in the thread's execution context. The WndProc() handles the SendMessage() calls as they come in. The problem is that the worker thread's WndProc() method is never triggered. Note, doExecute() is part of a template method that is called by my TThreadExtended class which is a descendant of Delphi's TThread. TThreadExtended implements the thread Execute() method and calls doExecute() in a loop. I triple-checked and doExecute() is being called repeatedly. Also note that I call PeekMessage() right after I create the WndProc() in order to make sure that Windows creates a message queue for the thread. However something I am doing is wrong since the WndProc() method is never triggered. Here's the code below: // ========= BEGIN: CLASS - TWorkerThread ======================== constructor TWorkerThread.Create; begin FWndProcHandle := 0; inherited Create(false); end; // --------------------------------------------------------------- // This call is the thread's Execute() method. procedure TWorkerThread.doExecute; var Msg: TMsg; begin // Create the WndProc() in our thread's context. if FWndProcHandle = 0 then begin FWndProcHandle := AllocateHWND(WndProc); // Call PeekMessage() to make sure we have a window queue. PeekMessage(Msg, FWndProcHandle, 0, 0, PM_NOREMOVE); end; if Self.Terminated then begin // Get rid of the WndProc(). myDeallocateHWnd(FWndProcHandle); end; // Sleep a bit to avoid hogging the CPU. Sleep(5); end; // --------------------------------------------------------------- procedure TWorkerThread.WndProc(Var Msg: TMessage); begin // THIS CODE IS NEVER CALLED. try if Msg.Msg = WM_COPYDATA then begin // Is LParam assigned? if (Msg.LParam > 0) then begin // Yes. Treat it as a copy data structure. with PCopyDataStruct(Msg.LParam)^ do begin ... // Here is where I do my work. end; end; // if Assigned(Msg.LParam) then end; // if Msg.Msg = WM_COPYDATA then finally Msg.Result := 1; end; // try() end; // --------------------------------------------------------------- procedure TWorkerThread.myDeallocateHWnd(Wnd: HWND); var Instance: Pointer; begin Instance := Pointer(GetWindowLong(Wnd, GWL_WNDPROC)); if Instance <> @DefWindowProc then begin // Restore the default windows procedure before freeing memory. SetWindowLong(Wnd, GWL_WNDPROC, Longint(@DefWindowProc)); FreeObjectInstance(Instance); end; DestroyWindow(Wnd); end; // --------------------------------------------------------------- // ========= END : CLASS - TWorkerThread ======================== Thanks, Robert

    Read the article

  • ORA-03113 in code. In addition, TNS-12535 and ORA-03137 in alert file

    - by user1348107
    I've got an exception that contain ORA-03113: (SiPPSS.GetPrintWorkDirectDetail) - ERR:ORA-03113: end-of-file on communication channel Process ID: 7448 Session ID: 30 Serial number: 9802 ?????:12110937 ????:T855 Oracle.DataAccess.Client.OracleException ORA-03113: end-of-file on communication channel Process ID: 7448 Session ID: 30 Serial number: 9802 ?? Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck) ?? Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, Boolean bCheck) ?? Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior) ?? Oracle.DataAccess.Client.OracleDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) ?? System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) ?? SiPPSS.VSireiMeisaiDsTableAdapters.V_SIREI_MEISAITableAdapter.FillByRunningNoAndProcNo(V_SIREI_MEISAIDataTable dataTable, String RUNNING_NO, String PROC_NO) ?? C:\SVM\trunk\SiPPSSServer\Server\Dao\View\VSireiMeisaiDs.Designer.vb:? 386 ?? SiPPSS.GetPrintWorkDirectDetail.Execute(BLogicParam param) ?? C:\SVM\trunk\SiPPSSServer\Server\BLogic\Screen\Printing\Rprt0701\GetPrintWorkDirectDetail.vb:? 105 In this case, the oracle alert log as beblow: Fatal NI connect error 12170. VERSION INFORMATION: TNS for 64-bit Windows: Version 11.2.0.1.0 - Production Oracle Bequeath NT Protocol Adapter for 64-bit Windows: Version 11.2.0.1.0 - Production Windows NT TCP/IP NT Protocol Adapter for 64-bit Windows: Version 11.2.0.1.0 - Production Time: 01-11?-2012 13:50:45 Tracing not turned on. Tns error struct: ns main err code: 12535 TNS-12535: TNS: ??????·???????? ns secondary err code: 12560 nt main err code: 505 TNS-00505: ??????????? nt secondary err code: 60 nt OS err code: 0 Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=10.41.102.53)(PORT=1794)) Thu Nov 01 13:54:17 2012 Thread 1 cannot allocate new log, sequence 1880 Private strand flush not complete Current log# 1 seq# 1879 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO01.LOG Thread 1 advanced to log sequence 1880 (LGWR switch) Current log# 2 seq# 1880 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO02.LOG Thu Nov 01 13:54:21 2012 Archived Log entry 1118 added for thread 1 sequence 1879 ID 0xe48db805 dest 1: Thu Nov 01 14:40:12 2012 Thread 1 cannot allocate new log, sequence 1881 Private strand flush not complete Current log# 2 seq# 1880 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO02.LOG Thread 1 advanced to log sequence 1881 (LGWR switch) Current log# 3 seq# 1881 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO03.LOG Thu Nov 01 14:40:16 2012 Archived Log entry 1119 added for thread 1 sequence 1880 ID 0xe48db805 dest 1: Thu Nov 01 15:27:42 2012 Thread 1 cannot allocate new log, sequence 1882 Private strand flush not complete Current log# 3 seq# 1881 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO03.LOG Thread 1 advanced to log sequence 1882 (LGWR switch) Current log# 1 seq# 1882 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO01.LOG Thu Nov 01 15:27:46 2012 Archived Log entry 1120 added for thread 1 sequence 1881 ID 0xe48db805 dest 1: Thu Nov 01 16:23:48 2012 Thread 1 cannot allocate new log, sequence 1883 Private strand flush not complete Current log# 1 seq# 1882 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO01.LOG Thread 1 advanced to log sequence 1883 (LGWR switch) Current log# 2 seq# 1883 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO02.LOG Thu Nov 01 16:23:52 2012 Archived Log entry 1121 added for thread 1 sequence 1882 ID 0xe48db805 dest 1: Thu Nov 01 17:05:50 2012 Thread 1 cannot allocate new log, sequence 1884 Private strand flush not complete Current log# 2 seq# 1883 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO02.LOG Thread 1 advanced to log sequence 1884 (LGWR switch) Current log# 3 seq# 1884 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO03.LOG Thu Nov 01 17:05:55 2012 Archived Log entry 1122 added for thread 1 sequence 1883 ID 0xe48db805 dest 1: Thu Nov 01 17:26:52 2012 Fatal NI connect error 12170. VERSION INFORMATION: TNS for 64-bit Windows: Version 11.2.0.1.0 - Production Oracle Bequeath NT Protocol Adapter for 64-bit Windows: Version 11.2.0.1.0 - Production Windows NT TCP/IP NT Protocol Adapter for 64-bit Windows: Version 11.2.0.1.0 - Production Time: 01-11?-2012 17:26:52 Tracing not turned on. Tns error struct: ns main err code: 12535 TNS-12535: TNS: ??????·???????? ns secondary err code: 12560 nt main err code: 505 TNS-00505: ??????????? nt secondary err code: 60 nt OS err code: 0 Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=10.41.102.62)(PORT=1286)) Thu Nov 01 17:27:16 2012 Fatal NI connect error 12170. VERSION INFORMATION: TNS for 64-bit Windows: Version 11.2.0.1.0 - Production Oracle Bequeath NT Protocol Adapter for 64-bit Windows: Version 11.2.0.1.0 - Production Windows NT TCP/IP NT Protocol Adapter for 64-bit Windows: Version 11.2.0.1.0 - Production Time: 01-11?-2012 17:27:16 Tracing not turned on. Tns error struct: ns main err code: 12535 TNS-12535: TNS: ??????·???????? ns secondary err code: 12560 nt main err code: 505 TNS-00505: ??????????? nt secondary err code: 60 nt OS err code: 0 Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=10.41.102.62)(PORT=1285)) Thu Nov 01 18:08:39 2012 Thread 1 advanced to log sequence 1885 (LGWR switch) Current log# 1 seq# 1885 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO01.LOG Thu Nov 01 18:08:40 2012 Archived Log entry 1123 added for thread 1 sequence 1884 ID 0xe48db805 dest 1: Thu Nov 01 19:33:21 2012 Thread 1 cannot allocate new log, sequence 1886 Private strand flush not complete Current log# 1 seq# 1885 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO01.LOG Thread 1 advanced to log sequence 1886 (LGWR switch) Current log# 2 seq# 1886 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO02.LOG Thu Nov 01 19:33:25 2012 Archived Log entry 1124 added for thread 1 sequence 1885 ID 0xe48db805 dest 1: Thu Nov 01 20:32:25 2012 Thread 1 cannot allocate new log, sequence 1887 Private strand flush not complete Current log# 2 seq# 1886 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO02.LOG Thread 1 advanced to log sequence 1887 (LGWR switch) Current log# 3 seq# 1887 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO03.LOG Thu Nov 01 20:32:29 2012 Archived Log entry 1125 added for thread 1 sequence 1886 ID 0xe48db805 dest 1: Thu Nov 01 21:13:07 2012 Thread 1 advanced to log sequence 1888 (LGWR switch) Current log# 1 seq# 1888 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO01.LOG Thu Nov 01 21:13:08 2012 Archived Log entry 1126 added for thread 1 sequence 1887 ID 0xe48db805 dest 1: Thu Nov 01 22:00:00 2012 Setting Resource Manager plan SCHEDULER[0x3006]:DEFAULT_MAINTENANCE_PLAN via scheduler window Setting Resource Manager plan DEFAULT_MAINTENANCE_PLAN via parameter Thu Nov 01 22:00:00 2012 Starting background process VKRM Thu Nov 01 22:00:00 2012 VKRM started with pid=32, OS id=4048 Thu Nov 01 22:00:59 2012 Thread 1 cannot allocate new log, sequence 1889 Private strand flush not complete Current log# 1 seq# 1888 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO01.LOG Thread 1 advanced to log sequence 1889 (LGWR switch) Current log# 2 seq# 1889 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO02.LOG Thu Nov 01 22:01:03 2012 Archived Log entry 1127 added for thread 1 sequence 1888 ID 0xe48db805 dest 1: Thu Nov 01 22:32:36 2012 Thread 1 advanced to log sequence 1890 (LGWR switch) Current log# 3 seq# 1890 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO03.LOG Thu Nov 01 22:32:37 2012 Archived Log entry 1128 added for thread 1 sequence 1889 ID 0xe48db805 dest 1: Thu Nov 01 22:33:18 2012 Errors in file d:\oracle\diag\rdbms\siporex\siporex\trace\siporex_ora_11884.trc (incident=101313): ORA-03137: TTC protocol internal error : [12333] [8] [49] [50] [] [] [] [] Incident details in: d:\oracle\diag\rdbms\siporex\siporex\incident\incdir_101313\siporex_ora_11884_i101313.trc Thu Nov 01 22:33:21 2012 Trace dumping is performing id=[cdmp_20121101223321] Thu Nov 01 22:40:43 2012 Thread 1 cannot allocate new log, sequence 1891 Private strand flush not complete Current log# 3 seq# 1890 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO03.LOG Thread 1 advanced to log sequence 1891 (LGWR switch) Current log# 1 seq# 1891 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO01.LOG Thu Nov 01 22:40:47 2012 Archived Log entry 1129 added for thread 1 sequence 1890 ID 0xe48db805 dest 1: Thu Nov 01 23:47:30 2012 Thread 1 cannot allocate new log, sequence 1892 Private strand flush not complete Current log# 1 seq# 1891 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO01.LOG Thread 1 advanced to log sequence 1892 (LGWR switch) Current log# 2 seq# 1892 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO02.LOG Thu Nov 01 23:47:34 2012 Archived Log entry 1130 added for thread 1 sequence 1891 ID 0xe48db805 dest 1: Fri Nov 02 00:49:31 2012 Thread 1 cannot allocate new log, sequence 1893 Private strand flush not complete Current log# 2 seq# 1892 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO02.LOG Thread 1 advanced to log sequence 1893 (LGWR switch) Current log# 3 seq# 1893 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO03.LOG Fri Nov 02 00:49:35 2012 Archived Log entry 1131 added for thread 1 sequence 1892 ID 0xe48db805 dest 1: Fri Nov 02 01:43:12 2012 Thread 1 cannot allocate new log, sequence 1894 Private strand flush not complete Current log# 3 seq# 1893 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO03.LOG Thread 1 advanced to log sequence 1894 (LGWR switch) Current log# 1 seq# 1894 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO01.LOG Fri Nov 02 01:43:17 2012 Archived Log entry 1132 added for thread 1 sequence 1893 ID 0xe48db805 dest 1: Fri Nov 02 01:52:51 2012 Errors in file d:\oracle\diag\rdbms\siporex\siporex\trace\siporex_ora_6124.trc (incident=101273): ORA-03137: TTC protocol internal error : [12333] [4] [80] [82] [] [] [] [] Incident details in: d:\oracle\diag\rdbms\siporex\siporex\incident\incdir_101273\siporex_ora_6124_i101273.trc Fri Nov 02 01:52:54 2012 Trace dumping is performing id=[cdmp_20121102015254] Fri Nov 02 02:00:00 2012 Clearing Resource Manager plan via parameter Fri Nov 02 02:43:37 2012 Thread 1 cannot allocate new log, sequence 1895 Private strand flush not complete Current log# 1 seq# 1894 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO01.LOG Thread 1 advanced to log sequence 1895 (LGWR switch) Current log# 2 seq# 1895 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO02.LOG Fri Nov 02 02:43:41 2012 Archived Log entry 1133 added for thread 1 sequence 1894 ID 0xe48db805 dest 1: Fri Nov 02 04:46:18 2012 Thread 1 cannot allocate new log, sequence 1896 Private strand flush not complete Current log# 2 seq# 1895 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO02.LOG Thread 1 advanced to log sequence 1896 (LGWR switch) Current log# 3 seq# 1896 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO03.LOG Fri Nov 02 04:46:22 2012 Archived Log entry 1134 added for thread 1 sequence 1895 ID 0xe48db805 dest 1: Fri Nov 02 04:51:41 2012 Errors in file d:\oracle\diag\rdbms\siporex\siporex\trace\siporex_ora_4048.trc (incident=101425): ORA-03137: TTC protocol internal error : [12333] [4] [67] [85] [] [] [] [] Incident details in: d:\oracle\diag\rdbms\siporex\siporex\incident\incdir_101425\siporex_ora_4048_i101425.trc Fri Nov 02 04:51:44 2012 Trace dumping is performing id=[cdmp_20121102045144] Fri Nov 02 05:54:44 2012 Thread 1 cannot allocate new log, sequence 1897 Private strand flush not complete Current log# 3 seq# 1896 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO03.LOG Thread 1 advanced to log sequence 1897 (LGWR switch) Current log# 1 seq# 1897 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO01.LOG Fri Nov 02 05:54:48 2012 Archived Log entry 1135 added for thread 1 sequence 1896 ID 0xe48db805 dest 1: Fri Nov 02 07:00:34 2012 Thread 1 cannot allocate new log, sequence 1898 Private strand flush not complete Current log# 1 seq# 1897 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO01.LOG Thread 1 advanced to log sequence 1898 (LGWR switch) Current log# 2 seq# 1898 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO02.LOG Fri Nov 02 07:00:38 2012 Archived Log entry 1136 added for thread 1 sequence 1897 ID 0xe48db805 dest 1: Fri Nov 02 08:32:41 2012 Thread 1 cannot allocate new log, sequence 1899 Private strand flush not complete Current log# 2 seq# 1898 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO02.LOG Thread 1 advanced to log sequence 1899 (LGWR switch) Current log# 3 seq# 1899 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO03.LOG Fri Nov 02 08:32:45 2012 Archived Log entry 1137 added for thread 1 sequence 1898 ID 0xe48db805 dest 1: Fri Nov 02 09:48:57 2012 Thread 1 advanced to log sequence 1900 (LGWR switch) Current log# 1 seq# 1900 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO01.LOG Fri Nov 02 09:48:58 2012 Archived Log entry 1138 added for thread 1 sequence 1899 ID 0xe48db805 dest 1: Fri Nov 02 10:18:15 2012 Thread 1 cannot allocate new log, sequence 1901 Private strand flush not complete Current log# 1 seq# 1900 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO01.LOG Thread 1 advanced to log sequence 1901 (LGWR switch) Current log# 2 seq# 1901 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO02.LOG Fri Nov 02 10:18:19 2012 Archived Log entry 1139 added for thread 1 sequence 1900 ID 0xe48db805 dest 1: Fri Nov 02 10:22:58 2012 Thread 1 cannot allocate new log, sequence 1902 Private strand flush not complete Current log# 2 seq# 1901 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO02.LOG Thread 1 advanced to log sequence 1902 (LGWR switch) Current log# 3 seq# 1902 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO03.LOG Fri Nov 02 10:23:02 2012 Archived Log entry 1140 added for thread 1 sequence 1901 ID 0xe48db805 dest 1: Fri Nov 02 10:27:38 2012 Thread 1 cannot allocate new log, sequence 1903 Checkpoint not complete Current log# 3 seq# 1902 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO03.LOG Thread 1 cannot allocate new log, sequence 1903 Private strand flush not complete Current log# 3 seq# 1902 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO03.LOG Thread 1 advanced to log sequence 1903 (LGWR switch) Current log# 1 seq# 1903 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO01.LOG Fri Nov 02 10:27:45 2012 Archived Log entry 1141 added for thread 1 sequence 1902 ID 0xe48db805 dest 1: Fri Nov 02 10:32:27 2012 Thread 1 cannot allocate new log, sequence 1904 Checkpoint not complete Current log# 1 seq# 1903 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO01.LOG Thread 1 cannot allocate new log, sequence 1904 Private strand flush not complete Current log# 1 seq# 1903 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO01.LOG Thread 1 advanced to log sequence 1904 (LGWR switch) Current log# 2 seq# 1904 mem# 0: D:\ORACLE\ORADATA\SIPOREX\REDO02.LOG Fri Nov 02 10:32:34 2012 Archived Log entry 1142 added for thread 1 sequence 1903 ID 0xe48db805 dest 1: Fri Nov 02 10:35:42 2012 Errors in file d:\oracle\diag\rdbms\siporex\siporex\trace\siporex_ora_15856.trc (incident=101353): ORA-03137: TTC protocol internal error : [12333] [8] [49] [50] [] [] [] [] Incident details in: d:\oracle\diag\rdbms\siporex\siporex\incident\incdir_101353\siporex_ora_15856_i101353.trc Fri Nov 02 10:35:44 2012 Trace dumping is performing id=[cdmp_20121102103544] I don't know main reason of this issue as well as how to fixing it. Please help me.

    Read the article

  • How to call a new thread from button click

    - by Lynnooi
    Hi, I'm trying to call a thread on a button click (btn_more) but i cant get it right. The thread is to get some data and update the images. The problem i have is if i only update 4 or 5 images then it works fine. But if i load more than 5 images i will get a force close. At times when the internet is slow I will face the same problem too. Can please help me to solve this problem or provide me some guidance? Here is the error i got from LogCat: 04-19 18:51:44.907: ERROR/AndroidRuntime(1034): Uncaught handler: thread main exiting due to uncaught exception 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): java.lang.NullPointerException 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at mobile9.android.gallery.GalleryWallpapers.setWallpaperThumb(GalleryWallpapers.java:383) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at mobile9.android.gallery.GalleryWallpapers.access$4(GalleryWallpapers.java:320) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at mobile9.android.gallery.GalleryWallpapers$1.handleMessage(GalleryWallpapers.java:266) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at android.os.Handler.dispatchMessage(Handler.java:99) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at android.os.Looper.loop(Looper.java:123) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at android.app.ActivityThread.main(ActivityThread.java:4310) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at java.lang.reflect.Method.invokeNative(Native Method) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at java.lang.reflect.Method.invoke(Method.java:521) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 04-19 18:51:44.927: ERROR/AndroidRuntime(1034): at dalvik.system.NativeStart.main(Native Method) My Code: public class GalleryWallpapers extends Activity implements Runnable { public static String MODEL = android.os.Build.MODEL ; private static final String rootURL = "http://www.uploadhub.com/mobile9/gallery/c/"; private int wallpapers_count = 0; private int ringtones_count = 0; private int index = 0; private int folder_id; private int page; private int page_counter = 1; private String family; private String keyword; private String xmlURL = ""; private String thread_op = "xml"; private ImageButton btn_back; private ImageButton btn_home; private ImageButton btn_filter; private ImageButton btn_search; private TextView btn_more; private ProgressDialog pd; GalleryExampleHandler myExampleHandler = new GalleryExampleHandler(); Context context = GalleryWallpapers.this.getBaseContext(); Drawable image; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MODEL = "HTC Legend"; // **needs to be remove after testing** try { MODEL = URLEncoder.encode(MODEL,"UTF-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.gallerywallpapers); Bundle b = this.getIntent().getExtras(); family = b.getString("fm").trim(); folder_id = Integer.parseInt(b.getString("fi")); keyword = b.getString("kw").trim(); page = Integer.parseInt(b.getString("page").trim()); WindowManager w = getWindowManager(); Display d = w.getDefaultDisplay(); final int width = d.getWidth(); final int height = d.getHeight(); xmlURL = rootURL + "wallpapers/1/?output=rss&afm=wallpapers&mdl=" + MODEL + "&awd=" + width + "&aht=" + height; if (folder_id > 0) { xmlURL = xmlURL + "&fi=" + folder_id; } pd = ProgressDialog.show(GalleryWallpapers.this, "", "Loading...", true, false); Thread thread = new Thread(GalleryWallpapers.this); thread.start(); btn_more = (TextView) findViewById(R.id.btn_more); btn_more.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { myExampleHandler.filenames.clear(); myExampleHandler.authors.clear(); myExampleHandler.duration.clear(); myExampleHandler.fileid.clear(); btn_more.setBackgroundResource(R.drawable.btn_more_click); page = page + 1; thread_op = "xml"; xmlURL = rootURL + "wallpapers/1/?output=rss&afm=wallpapers&mdl=" + MODEL + "&awd=" + width + "&aht=" + height; xmlURL = xmlURL + "&pg2=" + page; index = 0; pd = ProgressDialog.show(GalleryWallpapers.this, "", "Loading...", true, false); Thread thread = new Thread(GalleryWallpapers.this); thread.start(); } }); } public void run() { if(thread_op.equalsIgnoreCase("xml")){ readXML(); } else if(thread_op.equalsIgnoreCase("getImg")){ getWallpaperThumb(); } handler.sendEmptyMessage(0); } private Handler handler = new Handler() { @Override public void handleMessage(Message msg) { int count = 0; if (!myExampleHandler.filenames.isEmpty()){ count = myExampleHandler.filenames.size(); } count = 6; if(thread_op.equalsIgnoreCase("xml")){ pd.dismiss(); thread_op = "getImg"; btn_more.setBackgroundResource(R.drawable.btn_more); } else if(thread_op.equalsIgnoreCase("getImg")){ setWallpaperThumb(); index++; if (index < count){ Thread thread = new Thread(GalleryWallpapers.this); thread.start(); } } } }; private void readXML(){ if (xmlURL.length() != 0) { try { /* Create a URL we want to load some xml-data from. */ URL url = new URL(xmlURL); /* Get a SAXParser from the SAXPArserFactory. */ SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); /* Get the XMLReader of the SAXParser we created. */ XMLReader xr = sp.getXMLReader(); /* * Create a new ContentHandler and apply it to the * XML-Reader */ xr.setContentHandler(myExampleHandler); /* Parse the xml-data from our URL. */ xr.parse(new InputSource(url.openStream())); /* Parsing has finished. */ /* * Our ExampleHandler now provides the parsed data to * us. */ ParsedExampleDataSet parsedExampleDataSet = myExampleHandler .getParsedData(); } catch (Exception e) { //showDialog(DIALOG_SEND_LOG); } } } private void getWallpaperThumb(){ int i = this.index; if (!myExampleHandler.filenames.elementAt(i).toString().equalsIgnoreCase("")){ image = ImageOperations(context, myExampleHandler.thumbs.elementAt(i).toString(), "image.jpg"); } } private void setWallpaperThumb(){ int i = this.index; if (myExampleHandler.filenames.elementAt(i).toString() != null) { String file_info = myExampleHandler.filenames.elementAt(i).toString(); String author = "\nby " + myExampleHandler.authors.elementAt(i).toString(); final String folder = myExampleHandler.folder_id.elementAt(folder_id).toString(); final String fid = myExampleHandler.fileid.elementAt(i).toString(); ImageView imgView = new ImageView(context); TextView tv_filename = null; TextView tv_author = null; switch (i + 1) { case 1: imgView = (ImageView) findViewById(R.id.image1); tv_filename = (TextView) findViewById(R.id.filename1); tv_author = (TextView) findViewById(R.id.author1); break; case 2: imgView = (ImageView) findViewById(R.id.image2); tv_filename = (TextView) findViewById(R.id.filename2); tv_author = (TextView) findViewById(R.id.author2); break; case 3: imgView = (ImageView) findViewById(R.id.image3); tv_filename = (TextView) findViewById(R.id.filename3); tv_author = (TextView) findViewById(R.id.author3); break; case 4: . . . . . case 10: imgView = (ImageView) findViewById(R.id.image10); tv_filename = (TextView) findViewById(R.id.filename10); tv_author = (TextView) findViewById(R.id.author10); break; } if (image.getIntrinsicHeight() > 0) { imgView.setImageDrawable(image); } else { imgView.setImageResource(R.drawable.default_wallpaper); } tv_filename.setText(file_info); tv_author.setText(author); imgView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { // Perform action on click } }); } } private Drawable ImageOperations(Context ctx, String url, String saveFilename) { try { InputStream is = (InputStream) this.fetch(url); Drawable d = Drawable.createFromStream(is, "src"); return d; } catch (MalformedURLException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } } }

    Read the article

  • linux thread synchronization

    - by johnnycrash
    I am new to linux and linux threads. I have spent some time googling to try to understand the differences between all the functions available for thread synchronization. I still have some questions. I have found all of these different types of synchronizations, each with a number of functions for locking, unlocking, testing the lock, etc. gcc atomic operations futexes mutexes spinlocks seqlocks rculocks conditions semaphores My current (but probably flawed) understanding is this: semaphores are process wide, involve the filesystem (virtually I assume), and are probably the slowest. Futexes might be the base locking mechanism used by mutexes, spinlocks, seqlocks, and rculocks. Futexes might be faster than the locking mechanisms that are based on them. Spinlocks dont block and thus avoid context swtiches. However they avoid the context switch at the expense of consuming all the cycles on a CPU until the lock is released (spinning). They should only should be used on multi processor systems for obvious reasons. Never sleep in a spinlock. The seq lock just tells you when you finished your work if a writer changed the data the work was based on. You have to go back and repeat the work in this case. Atomic operations are the fastest synch call, and probably are used in all the above locking mechanisms. You do not want to use atomic operations on all the fields in your shared data. You want to use a lock (mutex, futex, spin, seq, rcu) or a single atomic opertation on a lock flag when you are accessing multiple data fields. My questions go like this: Am I right so far with my assumptions? Does anyone know the cpu cycle cost of the various options? I am adding parallelism to the app so we can get better wall time response at the expense of running fewer app instances per box. Performances is the utmost consideration. I don't want to consume cpu with context switching, spinning, or lots of extra cpu cycles to read and write shared memory. I am absolutely concerned with number of cpu cycles consumed. Which (if any) of the locks prevent interruption of a thread by the scheduler or interrupt...or am I just an idiot and all synchonization mechanisms do this. What kinds of interruption are prevented? Can I block all threads or threads just on the locking thread's CPU? This question stems from my fear of interrupting a thread holding a lock for a very commonly used function. I expect that the scheduler might schedule any number of other workers who will likely run into this function and then block because it was locked. A lot of context switching would be wasted until the thread with the lock gets rescheduled and finishes. I can re-write this function to minimize lock time, but still it is so commonly called I would like to use a lock that prevents interruption...across all processors. I am writing user code...so I get software interrupts, not hardware ones...right? I should stay away from any functions (spin/seq locks) that have the word "irq" in them. Which locks are for writing kernel or driver code and which are meant for user mode? Does anyone think using an atomic operation to have multiple threads move through a linked list is nuts? I am thinking to atomicly change the current item pointer to the next item in the list. If the attempt works, then the thread can safely use the data the current item pointed to before it was moved. Other threads would now be moved along the list. futexes? Any reason to use them instead of mutexes? Is there a better way than using a condition to sleep a thread when there is no work? When using gcc atomic ops, specifically the test_and_set, can I get a performance increase by doing a non atomic test first and then using test_and_set to confirm? *I know this will be case specific, so here is the case. There is a large collection of work items, say thousands. Each work item has a flag that is initialized to 0. When a thread has exclusive access to the work item, the flag will be one. There will be lots of worker threads. Any time a thread is looking for work, they can non atomicly test for 1. If they read a 1, we know for certain that the work is unavailable. If they read a zero, they need to perform the atomic test_and_set to confirm. So if the atomic test_and_set is 500 cpu cycles because it is disabling pipelining, causes cpu's to communicate and L2 caches to flush/fill .... and a simple test is 1 cycle .... then as long as I had a better ratio of 500 to 1 when it came to stumbling upon already completed work items....this would be a win.* I hope to use mutexes or spinlocks to sparilngly protect sections of code that I want only one thread on the SYSTEM (not jsut the CPU) to access at a time. I hope to sparingly use gcc atomic ops to select work and minimize use of mutexes and spinlocks. For instance: a flag in a work item can be checked to see if a thread has worked it (0=no, 1=yes or in progress). A simple test_and_set tells the thread if it has work or needs to move on. I hope to use conditions to wake up threads when there is work. Thanks!

    Read the article

  • killing a separate thread having a socket

    - by user311906
    Hi All I have a separate thread ListenerThread having a socket listening to info broadcasted by some remote server. This is created at the constructor of one class I need to develop. Because of requirements, once the separate thread is started I need to avoid any blocking function on the main thread. Once it comes to the point of calling the destructor of my class I cannot perform a join on the listener thread so the only thing I can do is to KILL it. My questions are: what happens to the network resoruces allocated by the function passed to the thead? Is the socket closed properly or there might be something pending? ( most worried about this ) is this procedure fast enough i.e. is the thread killed so that interrupt immediately ? I am working with Linux ...what command or what can I check to ensure that there is no networking resource left pending or that something went wrong for the Operating system I thank you very much for your help Regards MNSTN NOTE: I am using boost::thread in C++

    Read the article

  • Proper way to have an endless worker thread?

    - by Neil N
    I have an object that requires a lot of initialization (1-2 seconds on a beefy machine). Though once it is initialized it only takes about 20 miliseconds to do a typical "job" In order to prevent it from being re-initialized every time an app wants to use it (which could be 50 times a second or not at all for minutes in typical usage), I decided to give it a job que, and have it run on its own thread, checking to see if there is any work for it in the que. However I'm not entirely sure how to make a thread that runs indefinetly with or without work. Here's what I have so far, any critique is welcomed private void DoWork() { while (true) { if (JobQue.Count > 0) { // do work on JobQue.Pop() } else { System.Threading.Thread.Sleep(50); } } } After thought: I was thinking I may need to kill this thread gracefully insead of letting it run forever, so I think I will add a Job type that tells the thread to end. Any thoughts on how to end a thread like this also appreciated.

    Read the article

  • c++ thread running time

    - by chnet
    I want to know whether I can calculate the running time for each thread. I implement a multithread program in C++ using pthread. As we know, each thread will compete the CPU. Can I use clock() function to calculate the actual number of CPU clocks each thread consumes? my program looks like: Class Thread () { Start(); Run(); Computing(); }; Start() is to start multiple threads. Then each thread will run Computing function to do something. My question is how I can calculate the running time of each thread for Computing function

    Read the article

  • How to tell if there is an available thread in a thread pool in java

    - by Gormcito
    I am trying to proccess a queue of tasks from a database table as fast as possible while also limiting the number of threads to process the tasks. I am using a fixed sized thread pool with Executors.newFixedThreadPool(N); I want to know if there is a way of knowing if the thread pool is full, by that I mean are there currently 50 threads running, if so then I'll wait for a thread to be available before starting a new one instead of sleeping the main thread. Code of what I would like to do: ExecutorService executor = Executors.newFixedThreadPool(N); ResultSet results; while( true ) { results = getWaitingTasksStmt.executeQuery(); while( results.next() && executor.notFull() ) { executor.submit( new thread( new runnableInheritedClass(results) ) ); } }

    Read the article

  • Thread 0 crashed with X86 Thread State (32-bit): in cocoa Application

    - by John
    I am doing crash fixing in an osx application .The crash report shows Date/Time: 2012-05-01 16:05:58.004 +0200 OS Version: Mac OS X 10.5.8 (9L31a) Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x00000000545f5f00 Crashed Thread: 8 Thread 8 crashed with X86 Thread State (32-bit): eax: 0x140e0850 ebx: 0x00060fc8 ecx: 0x92df0ec0 edx: 0xc0000003 edi: 0x545f5f00 esi: 0x140e0870 ebp: 0xb0445988 esp: 0xb0445964 ss: 0x0000001f efl: 0x00010206 eip: 0x92dca68c cs: 0x00000017 ds: 0x0000001f es: 0x0000001f fs: 0x0000001f gs: 0x00000037 cr2: 0x545f5f00 How to tares the application code with this report? what is Thread 0 crashed with X86 Thread State (32-bit)? if anybody know please help me. Thanks in advance.

    Read the article

  • Catch a thread's exception in the caller thread in Python

    - by Mikee
    Hi Everyone, I'm very new to Python and multithreaded programming in general. Basically, I have a script that will copy files to another location. I would like this to be placed in another thread so I can output "...." to indicate that the script is still running. The problem that I am having is that if the files cannot be copied it will throw an exception. This is ok if running in the main thread; however, having the following code does not work: try: threadClass = TheThread(param1, param2, etc.) threadClass.start() ##### **Exception takes place here** except: print "Caught an exception" In the thread class itself, I tried to re-throw the exception, but it does not work. I have seen people on here ask similar questions, but they all seem to be doing something more specific than what I am trying to do (and I don't quite understand the solutions offered). I have seen people mention the usage of sys.exc_info(), however I do not know where or how to use it. All help is greatly appreciated! EDIT: The code for the thread class is below: class TheThread(threading.Thread): def __init__(self, sourceFolder, destFolder): threading.Thread.__init__(self) self.sourceFolder = sourceFolder self.destFolder = destFolder def run(self): try: shul.copytree(self.sourceFolder, self.destFolder) except: raise

    Read the article

  • Suggestions for lightweight, thread-safe scheduler

    - by nirvanai
    I am trying to write a round-robin scheduler for lightweight threads (fibers). It must scale to handle as many concurrently-scheduled fibers as possible. I also need to be able to schedule fibers from threads other than the one the run loop is on, and preferably unschedule them from arbitrary threads as well (though I could live with only being able to unschedule them from the run loop). My current idea is to have a circular doubly-linked list, where each fiber is a node and the scheduler holds a reference to the current node. This is what I have so far: using Interlocked = System.Threading.Interlocked; public class Thread { internal Future current_fiber; public void RunLoop () { while (true) { var fiber = current_fiber; if (fiber == null) { // block the thread until a fiber is scheduled continue; } if (fiber.Fulfilled) fiber.Unschedule (); else fiber.Resume (); //if (current_fiber == fiber) current_fiber = fiber.next; Interlocked.CompareExchange<Future> (ref current_fiber, fiber.next, fiber); } } } public abstract class Future { public bool Fulfilled { get; protected set; } internal Future previous, next; // this must be thread-safe // it inserts this node before thread.current_fiber // (getting the exact position doesn't matter, as long as the // chosen nodes haven't been unscheduled) public void Schedule (Thread thread) { next = this; // maintain circularity, even if this is the only node previous = this; try_again: var current = Interlocked.CompareExchange<Future> (ref thread.current_fiber, this, null); if (current == null) return; var target = current.previous; while (target == null) { // current was unscheduled; negotiate for new current_fiber var potential = current.next; var actual = Interlocked.CompareExchange<Future> (ref thread.current_fiber, potential, current); current = (actual == current? potential : actual); if (current == null) goto try_again; target = current.previous; } // I would lock "current" and "target" at this point. // How can I do this w/o risk of deadlock? next = current; previous = target; target.next = this; current.previous = this; } // this would ideally be thread-safe public void Unschedule () { var prev = previous; if (prev == null) { // already unscheduled return; } previous = null; if (next == this) { next = null; return; } // Again, I would lock "prev" and "next" here // How can I do this w/o risk of deadlock? prev.next = next; next.previous = prev; } public abstract void Resume (); } As you can see, my sticking point is that I cannot ensure the order of locking, so I can't lock more than one node without risking deadlock. Or can I? I don't want to have a global lock on the Thread object, since the amount of lock contention would be extreme. Plus, I don't especially care about insertion position, so if I lock each node separately then Schedule() could use something like Monitor.TryEnter and just keep walking the list until it finds an unlocked node. Overall, I'm not invested in any particular implementation, as long as it meets the requirements I've mentioned. Any ideas would be greatly appreciated. Thanks! P.S- For the curious, this is for an open source project I'm starting at http://github.com/nirvanai/Cirrus

    Read the article

  • evaluation of a java thread dump

    - by raticulin
    I got a thread dump of one of my processes. It has a bunch of these threads. I guess they are keeping a bunch of memory so I am getting OOM. "Thread-8264" prio=6 tid=0x4c94ac00 nid=0xf3c runnable [0x4fe7f000] java.lang.Thread.State: RUNNABLE at java.util.zip.Inflater.inflateBytes(Native Method) at java.util.zip.Inflater.inflate(Inflater.java:223) - locked <0x0c9bc640 (a java.util.zip.Inflater) at org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.read(ZipArchiveInputStream.java:235) at com.my.ZipExtractorCommonsCompress.extract(ZipExtractorCommonsCompress.java:48) at com.my.CustomThreadedExtractorWrapper$ExtractionThread.run(CustomThreadedExtractorWrapper.java:151) Locked ownable synchronizers: - None "Thread-8241" prio=6 tid=0x4c94a400 nid=0xb8c runnable [0x4faef000] java.lang.Thread.State: RUNNABLE at java.util.zip.Inflater.inflateBytes(Native Method) at java.util.zip.Inflater.inflate(Inflater.java:223) - locked <0x0c36b808 (a java.util.zip.Inflater) at org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.read(ZipArchiveInputStream.java:235) at com.my.ZipExtractorCommonsCompress.extract(ZipExtractorCommonsCompress.java:48) at com.my.CustomThreadedExtractorWrapper$ExtractionThread.run(CustomThreadedExtractorWrapper.java:151) Locked ownable synchronizers: - None I am trying to find out how it arrived to this situation. CustomThreadedExtractorWrapper is a wrapper class that fires a thread to do some work (ExtractionThread, which uses ZipExtractorCommonsCompress to extract zip contents from a compressed stream). If the task is taking too long, ExtractionThread.interrupt(); is called to cancel the operation. I can see in my logs that the cancellation happened 25 times. And I see 21 of these threads in my dump. My questions: What is the status of these threads? Alive and running? Blocked somehow? They did not die with .interrupt() apparently? Is there a sure way to really kill a thread? What does really mean 'locked ' in the stack trace? Line 223 in Inflater.java is: public synchronized int inflate(byte[] b, int off, int len) { ... //return is line 223 return inflateBytes(b, off, len); }

    Read the article

  • Thread Safety of C# List<T> for readers

    - by ILIA BROUDNO
    I am planning to create the list once in a static constructor and then have multiple instances of that class read it (and enumerate through it) concurrently without doing any locking. In this article http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx MS describes the issue of thread safety as follows: Public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. A List can support multiple readers concurrently, as long as the collection is not modified. Enumerating through a collection is intrinsically not a thread-safe procedure. In the rare case where an enumeration contends with one or more write accesses, the only way to ensure thread safety is to lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. The "Enumerating through a collection is intrinsically not a thread-safe procedure." Statement is what worries me. Does this mean that it is thread safe for readers only scenario, but as long as you do not use enumeration? Or is it safe for my scenario?

    Read the article

  • java - question about thread abortion and deadlock - volatile keyword

    - by Tiyoal
    Hello all, I am having some troubles to understand how I have to stop a running thread. I'll try to explain it by example. Assume the following class: public class MyThread extends Thread { protected volatile boolean running = true; public void run() { while (running) { synchronized (someObject) { while (someObject.someCondition() == false && running) { try { someObject.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } // do something useful with someObject } } } public void halt() { running = false; interrupt(); } } Assume the thread is running and the following statement is evaluated to true: while (someObject.someCondition() == false && running) Then, another thread calls MyThread.halt(). Eventhough this function sets 'running' to false (which is a volatile boolean) and interrupts the thread, the following statement is still executed: someObject.wait(); We have a deadlock. The thread will never be halted. Then I came up with this, but I am not sure if it is correct: public class MyThread extends Thread { protected volatile boolean running = true; public void run() { while (running) { synchronized (someObject) { while (someObject.someCondition() == false && running) { try { someObject.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } // do something useful with someObject } } } public void halt() { running = false; synchronized(someObject) { interrupt(); } } } Is this correct? Is this the most common way to do this? This seems like an obvious question, but I fail to come up with a solution. Thanks a lot for your help.

    Read the article

  • Is SecureRandom thread safe?

    - by Yishai
    Is SecureRandom thread safe? That is, after initializing it, can access to the next random number be relied on to be thread safe? Examining the source code seems to show that it is, and this bug report seems to indicate that its lack of documentation as thread safe is a javadoc issue. Has anyone confirmed that it is in fact thread safe?

    Read the article

  • How a thread should close itself in Java?

    - by Roman
    This is a short question. At some point my thread understand that it should suicide. What is the best way to do it: Thread.currentThread().interrupt(); return; By the way, why in the first case we need to use currentThread? Is Thread does not refer to the current thread?

    Read the article

  • .NET threading: how can I capture an abort on an unstarted thread?

    - by Groxx
    I have a chunk of threads I wish to run in order, on an ASP site running .NET 2.0 with Visual Studio 2008 (no idea how much all that matters, but there it is), and they may have aborted-clean-up code which should be run regardless of how far through their task they are. So I make a thread like this: Thread t = new Thread(delegate() { try { /* do things */ System.Diagnostics.Debug.WriteLine("try"); } catch (ThreadAbortException) { /* cleanup */ System.Diagnostics.Debug.WriteLine("catch"); } }); Now, if I wish to abort the set of threads part way through, the cleanup may still be desirable later on down the line. Looking through MSDN implies you can .Abort() a thread that has not started, and then .Start() it, at which point it will receive the exception and perform normally. Or you can .Join() the aborted thread to wait for it to finish aborting. Presumably you can combine them. http://msdn.microsoft.com/en-us/library/ty8d3wta(v=VS.80).aspx To wait until a thread has aborted, you can call the Join method on the thread after calling the Abort method, but there is no guarantee the wait will end. If Abort is called on a thread that has not been started, the thread will abort when Start is called. If Abort is called on a thread that is blocked or is sleeping, the thread is interrupted and then aborted. Now, when I debug and step through this code: t.Abort(); // ThreadState == Unstarted | AbortRequested t.Start(); // throws ThreadStartException: "Thread failed to start." // so I comment it out, and t.Join(); // throws ThreadStateException: "Thread has not been started." At no point do I see any output, nor do any breakpoints on either the try or catch block get reached. Oddly, ThreadStartException is not listed as a possible throw of .Start(), from here: http://msdn.microsoft.com/en-us/library/a9fyxz7d(v=VS.80).aspx (or any other version) I understand this could be avoided by having a start parameter, which states if the thread should jump to cleanup code, and foregoing the Abort call (which is probably what I'll do). And I could .Start() the thread, and then .Abort() it. But as an indeterminate amount of time may pass between .Start and .Abort, I'm considering it unreliable, and the documentation seems to say my original method should work. Am I missing something? Is the documentation wrong? edit: ow. And you can't call .Start(param) on a non-parameterized Thread(Start). Is there a way to find out if a thread is parameterized or not, aside from trial and error? I see a private m_Delegate, but nothing public...

    Read the article

  • C# thread with multiple parameters

    - by Lucas B
    Does anyone know how to pass multiple parameters into a Thread.Start routine? I thought of extending the class, but the C# Thread class is sealed. Here is what I think the code would look like: ... Thread standardTCPServerThread = new Thread(startSocketServerAsThread); standardServerThread.Start( orchestrator, initializeMemberBalance, arg, 60000); ... } static void startSocketServerAsThread(ServiceOrchestrator orchestrator, List<int> memberBalances, string arg, int port) { startSocketServer(orchestrator, memberBalances, arg, port); } Thank you in advance. BTW, I start a number of threads with different orchestrators, balances and ports. Please consider thread safety also.

    Read the article

  • Using EnterCriticalSection in Thread to update VCL label

    - by user257188
    I'm new to threads. I'm using a 3rd party library that uses threads which at times call a procedure I've provided. How do I update update a TLabel.Caption from my procedure when its called by the thread? If I've called InitializeCriticalSection elsewhere, is it as simple as EnterCriticalSection(CritSect); GlobalVariable := 'New TLabel.Caption'; LeaveCriticalSection(CritSect); And then in my main thread: EnterCriticalSection(CritSect); Label1.Caption:= 'New TLable.Caption'; LeaveCriticalSection(CritSect); But, how do I get the main thread code to be called? The thread can use SendMessage? Or is there some better/easier way (.OnIdle could check a flag set by the thread?) Thanks.

    Read the article

  • Thread local storage with __declspec(thread) fails in C++/CLI

    - by EFrank
    I'm working on a project where we mix .NET code and native C++ code via a C++/CLI layer. In this solution I want to use Thread Local Storage via the __declspec(thread) declaration: __declspec(thread) int lastId = 0; However, at the first access of the variable, I get a NullReferenceException. To be more precise, the declaration is done within a ref class (a .NET class implemented in C++/CLI). I have already read something about __declspec(thread) does not work with delay loaded DLLs. Am I using delay loaded DLLs automatically if I use .NET?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >