Close a blocking wait thrad by another thread

Hi all
I have a lookup method which makes a blocking wait and I want to close this lookup if the content not available for 10 seconds.
What I have done is put this lookup in a thread(LookupThread) and used separate thread(TimeCheckThread) for calculate the elapsed time.
This is my idea
public class LookupThread extends Thread
    Calendar cal = Calendar.getInstance();
    boolean closed = false;
    public TimeCheckThread getTimeChecker()
        return new TimeCheckThread();
    public void run()
        lookMethod(); // this is the blocking wait
    public class TimeCheckThread extends Thread
        long startTime = cal.getTimeInMillis();
        public void run()
            // strted looking for elapsed time
            while(true)
                cal = Calendar.getInstance();
                if(cal.getTimeInMillis()-startTime > 10000 & !closed)
                    // if 10 seconds elapsed close the thread which makes the blocking wait
                    LookupThread.super.stop();
                    closed = true;
                    // to exit from time check thread
                    break;
    public static void main(String args[])
        LookupThread v = new LookupThread();
        v.getTimeChecker().start();
        v.start();
}The problem is closing of thread is deprecated.
LookupThread.super.stop();So any idea to handle those blocking wait situations and assign a return time other than this approach?

WirajR wrote:
Also TimeCheckThread eats of CPU time for 10 seconds use a java.util.Timer instead
>Also TimeCheckThread eats of CPU time for 10 seconds use a java.util.Timer instead
Hi
I think this is the most suit to my requirement. Totally different way, but acceptable.
To EJP
Ur solution seems great to replace following code segment
public class TimeCheckThread extends Thread
        long startTime = cal.getTimeInMillis();
        public void run()
            // strted looking for elapsed time
            while(true)
                cal = Calendar.getInstance();
                if(cal.getTimeInMillis()-startTime > 10000 & !closed)
                    // if 10 seconds elapsed close the thread which makes the blocking wait
                    LookupThread.super.stop();
                    closed = true;
                    // to exit from time check thread
                    break;
    }like following
public class TimeCheckThread extends Thread
       public void run()
                    TimeCheckThread.sleep(10000);
                    LookupThread.super.stop();
}To Peter__Lawrey
Why don't you make the blocking lookup block for only 10 seconds?Any idea to implement such blocking lookup block?
My blocking operation is a looking for RTP video stream. It waits until server sends the video

Similar Messages

  • Running another thread not to block UI

    I do some heavy operation inside the actionPerformed (load images from File Chooser, resize it for display and populate it in the ScrollPane etc) and I realize that the windows freezes until the whole operation is finished. And it doesn't really help that I do repaint() or validate(). I make some research and some of the books and people from forums say that I actually needed to dispatch another thread to run the heavy operation. So that I won't block the UI interface and can update things accordingly. But the problem is, I don't have any clear example to understand this concept. How to clean up the thread after operation finished. How can a thread notify the progress back and etc. I need to know how much images has been loaded so that I can update the progress bar and so on. Can anyone help me point out a good example? :D

    Think I should show my code snippet to you
    public void actionPerformed(ActionEvent e) {
            if (e.getSource() == BtnBrowse) {
                int returnVal = fcSelectFile.showDialog(this,"Select");
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    file= fcSelectFile.getSelectedFiles();
                    //This is where a real application would open the file.
                    Thread worker=new Thread(){
                            public void run(){
                                int count=0;
                                selectedFile=new JLabel[file.length]; 
                                while(count<file.length)
                                {   final int index=count;
                                    String actualFile=file[count].toString();
                                    String fileName= file[count].getName();
                                    selectedFile[count]=new JLabel(createImageIcon(actualFile,fileName));
                                    SwingUtilities.invokeLater(new Runnable(){
                                    public void run(){
                                    PnlImageHolder.add(selectedFile[index]);
                                    PnlImageHolder.repaint();
                                    PnlImageHolder.validate();
                                    count++;
                    worker.start();
                    ScpImageScroller.getViewport().add(PnlImageHolder);
    }

  • Write blocked waiting on read

    Hi all,
    I have been experiencing difficulties with simultaneous read/write with AsyncIO. For my scenario that the client/server application is being developed, a client may send requests or status information at any given time. Hence continual monitoring on the incoming stream is required.
    The server shall respond depending upon the status message requiring a write to the client (so it won't respond to all messages received). Likewise, the client in some instances will only send status messages depending on the last message it received from the server.
    I've been experiencing difficulties with writes blocking because of reading. Essentially I would like to continually poll reading whilst allowing writes to be flushed immediately.
    Using traditional blocking read/writes things hang indefinitely whilst attempting to write a message as reading has blocked waiting for input.
    Using the IBM AsyncIO package (which is purported to be faster implementation of NIO), writing blocks for some time until reading (i assume) relinquishes the socket to allow writing to occur before resuming reading again. The lag time in this situation is significant.
    Is someone able to provide an example using non-blocking R/W in which a server can sit reading (on one thread) whilst the writing is attempted on another thread that doesn't cause any lag?
    Below is a basic overview of what is happening in my software:
    public class MessageQueue {
       private LinkedList<Message> queue;
       /** Creates a new instance of MessageQueue */
       public MessageQueue() {
          queue = new LinkedList<Message>();
       public synchronized void put(Message message) {
          queue.add( message );
          notifyAll();
       public synchronized boolean isEmpty() {
          return queue.isEmpty();
       public synchronized Message get() {
          while( queue.isEmpty() ) {
             try {
                wait();
             } catch( InterruptedException ie ) {
          Message message = ( Message )queue.removeFirst();
          return message;
       public synchronized void close() {
          queue.clear();
          queue = null;
    public class InputReader implements Runnable {
      private MessageQueue messages;
      private AsyncSocketChannel async_channel;
      public InputReader(MessageQueue messages, AsyncSocketChannel async_channel) {
        this.messages = messages;
        this.async_channel = async_channel;
      public long read(ByteBuffer b) {
         long bytes_read = 0;
         helper = new AsyncSocketChannelHelper( this.async_channel );
         future = channel.read(b);
         bytes_read = future.getByteCount( );
         return bytes_read;
      public void run() {
         ByteBuffer b = ByteBuffer.allocateDirect(Message.SIZE);
         boolean running = true;
         while(running) {
            if (read(b) == 0)
              running = false;
            else
              messages.put(new Message(b));
    public class OutputWriter implements Runnable {
      private MessageQueue messages;
      private AsyncSocketChannel async_channel;
      public OutputWriter(MessageQueue messages, AsyncSocketChannel async_channel) {
        this.messages = messages;
        this.async_channel = async_channel;
      public long write(ByteBuffer b) {
          long bytes_written = 0;
          try {
             AsyncSocketChannelHelper helper = new AsyncSocketChannelHelper( this.async_channel );
             IAsyncFuture future = helper.write(b, 20000); // write or timeout
             // wait for completion of write, or for the timeout to happen
             bytes_written = future.getByteCount( );
             // THIS IS WHERE THE PROBLEM LIES. The write does not happen straight away because of the read operation. With traditional blocking IO this locks completely.
          } catch ( AsyncTimeoutException ate) {
                  System.err.println("Timed out after 20 seconds");
          return bytes_written;
       public void run() {
         boolean running = true;
         while(running) {
            Message m = this.messages.get();
            if (write(m.getByteBuffer()) == 0)
              running = false;
            else
              messages.put(new Message(b));
    public class Controller {
       public Controller(AsyncSocketChannel async_channel) {
            MessageQueue in = new MessageQueue();
            MessageQueue out = new MessageQueue();
            InputReader ir = new InputReader(out, async_channel);
            OutputWriter ow = new OutputWriter(out, async_channel);
            new Thread(ow).start();
            new Thread(ir).start();
            boolean running = true;
            Message m;
            while(running) {
               m = in.get();
               if (m.getStatus() == "REQUIRES_RESPONSE"))
                 out.put(m); // dummy example to demonstrate that once the right condition is met, a new message must be written
    }

    That makes me wonder what the problem is I am experiencing then.
    I initially had stock-standard java.net IO for socket reading and writing. The approach I took was to set up an input reader on its own thread and an output writer on its own thread.
    When it came to writing data however, things locked up. Stepping through the code in debug mode allowed me to see that the write method was not completing because the read method was waiting for input to come in.
    I tested it using traditional buffered output which made a call to flush() afterwards, but it was getting stuck on the write() call.
    I came to the conclusion that the read must be blocking the write from completing because of the response to this thread: http://forum.java.sun.com/thread.jspa?forumID=536&threadID=750707
    On further debugging, write() never locked up when I didn't allow the input reader to perform a simultaneous read() on the socket.
    Hence my belief that the java.net socket does block when one operation is being performed.
    After dealing with IBM's AsyncIO package I'd be willing to wager that their ibmaio package is 50x more complex to use than standard Java sockets (barely any documentation/examples) so 10x complexity seems positively lightweight ;-)
    So ejp, to clarify, would NIO help solve this blocking problem or do you think something else is the culprit? It is hard to see what as to test things out I made two bare bones testing programs (one client and the other a server) so I don't feel it could be anything else in the code.
    Thoughts?

  • Shutting down a panel in one thread from another thread.

    For various reasons, I have a program with two threads (actually more than two, but only two are concerned here). One is the main panel that runs at startup, another is a Virtual O'Scope panel with a real-time display. Everything works more or less well, until it's time to exit the program.
    The main program starts by calling a routine to display the VO'scope; this routine calls CmtScheduleThreadPoolFunctionAdv to schedule the VOscope thread with the function VOscopePanelMain.
    VOscopePanelMain initializes things, displays the VOscope panel, and then calls RunUserInterface(); to process events in the VOscope panel.
    When it comes time to close the window, closing the panel (the X box in the upper right corner) triggers the panel callback CB_VoscopePanel, which processes the EVENT_CLOSE: event by calling QuitUserInterface(0); which, in turn, causes RunUserInterface to return to VOscopePanelMain, which then shuts things down, closes the panel properly, and exits. So far so good.
    int CVICALLBACK CB_VoscopePanel (int panel, int event, void *callbackData,
            int eventData1, int eventData2)
        int    iPanelHeight, iPanelWidth, iV2ControlLeft, iV2ControlWidth, iWidth,
            iT2ControlTop, iT2ControlHeight, iHeight, iLeft, iGap, iScreenTop, iScreenLeft,
            iTop, iBoxWidth;
        switch (event) {
            break;
        case EVENT_GOT_FOCUS: //happens when first displayed or refreshed
        case EVENT_PANEL_SIZE: //size the controls on the panel
           ... do stuff here;
            break;
        case EVENT_CLOSE:
            QuitUserInterface(0);  //stop VOscopePanelMain, which in turn closes the panel and cleans stuff up.
            break;
        return 0;
    However, I also want the panel to stop when I close the main program. The only way that I know how to do this cleanly is to have the main program (which has closed all of its panels and is in the process of shutting down) call VOSCOPE_Close_VOScope () which, in turn, calls CallPanelCallback (iHandle_VOscope, EVENT_CLOSE, 0, 0, 0); (which forces a call to CB_VoscopePanel above with the EVENT_CLOSE event), which should call QuitUserInterface, which should cause the RunUserInterface in VOscopePanelMain to return and let it continue to shut down. In addition, after calling CallPanelCallback, the shutdown routine calls CmtWaitForThreadPoolFunctionCompletion to wait for the VOscopePanelMain thread to actually quit and clean up before proceeding.
    But, of course, it doesn't since, and it took me a while to realize this. The call to QuitUserInterface isn't coming from inside of the VOscopePanelMain thread, it's coming from the main panel's thread - which is already in the process of shutting down. So, the main panel thread is telling itself to quit, VOscopePanelMain never gets the QuitUserInterface message, and things stall.
    So: how do I have one thread tell a panel in another thread to cleanly close? Or do I have to get complicated and either replace RunUserInterface in VOscopePanelMain with a loop that processes events manually and looks for a flag, or figure out something with a thread-safe queue? Any help appreciated.
    Attachments:
    Voscope.c ‏76 KB

    Sorry for delay in answering, it took me a while to find time to build up a working example.
    The attached program spawns a thread in a new thread pool and permit you to choose whether to close it from the main thread or the spawned thread itself.
    It appears that in such a minimal configuration the process works as expected. There may be some different configuration in your actual program that prevents this.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?
    Attachments:
    ThreadPoolWithGUI.zip ‏7 KB

  • Close the current UI and open another one

    Hello everyone,
    I've got the following code and I want to close the current window and open another one. When i use "System.exit(1);" it closes everything when I use "this.dispose()" it doesn't close anything what could I try to get this to work? any suggestions?
    the code is:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    //public class Equip_or_Job implements ActionListener {
    public class Equip_or_Job extends Frame implements ActionListener {
        JFrame dFrame;
        JPanel jePanel;
        JButton choice;
        JComboBox jeqid = new JComboBox();
        public Equip_or_Job() {
            //Create and set up the window.
            dFrame = new JFrame("Work with Jobid or Equipid");
            dFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the panel.
            jePanel = new JPanel(new GridLayout(2, 1));
            dFrame.getContentPane().setLayout(new BorderLayout());
            //Add the widgets.
            addWidgets();
            //Set the default button.
            dFrame.getRootPane().setDefaultButton(choice);
            //Add the panel to the window.
            dFrame.getContentPane().add(jePanel, BorderLayout.CENTER);
            //Display the window.
            dFrame.pack();
            dFrame.setVisible(true);
    Create and add the widgets.
        private void addWidgets() {
             //Create widgets.
              jeqid.addItem("Chose by Job");
              jeqid.addItem("Chose by Equipment");
              choice = new JButton("Chose");
                //Listen to events from the Convert button.
                choice.addActionListener(this);
              jePanel.add(jeqid);
              jePanel.add(choice);
        public void actionPerformed(ActionEvent event) {
              String sel = (String) jeqid.getSelectedItem();
            if("Chose by Job".equals(sel)){
                   InsertNewDates inj = new InsertNewDates();
                   //System.exit(1);
                   dispose();
              else if("Chose by Equipment".equals(sel)){
                   InsertNewDates ineq = new InsertNewDates();
                   //System.exit(1);
                   dispose();
    Create the GUI and show it.  For thread safety,
    this method should be invoked from the
    event-dispatching thread.
        private static void createAndShowGUI() {
            //Make sure we have nice window decorations.
            try {
                   UIManager.setLookAndFeel(
                        UIManager.getCrossPlatformLookAndFeelClassName());
              catch (Exception e) { }
            Equip_or_Job eorj = new Equip_or_Job();
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    thanks in advance :o)

    I'm not exactly sure what you want to do, but...:
    dFrame.setVisible(false) hides the current Frame and the application is still running
    Best reagrds, Marco

  • Very high data block waits

    I have one table xxxx in a tablespace tbx and the tablespace tbx has only 1 datafile. The table xxxx size is 890MB w/ 14 millions records. The datafile size is 2048MB. This table is a frequently access with insert/delete/select. The system spends alot of time waiting on this datafile. If I create a new tablespace abc with 20 datafiles worth about 100MB each, would it help reducing the data block wait count? The pctfree/pctused is 10/40 respectively.
    Can anyone please give me an how to resolve this?

    I am looking at an Oracle Statistics. We use SAN technology with RAID 0+1 Striped across all disks.
    First I use this query to get the wait statistics:
    select time, count, class
    from v$waitstat
    order by time, count;
    From this query above, I got this result and database just been up 02/17/2004, just about 4 days ago:
    TIME COUNT CLASS
    0 0 sort block
    0 0 save undo block
    0 0 save undo header
    0 0 free list
    0 0 bitmap block
    0 0 unused
    0 0 system undo block
    0 0 system undo header
    0 0 bitmap index block
    10 10 extent map
    48 656 undo header
    271 853 undo block
    301 730 segment header
    780382 1214405 data block
    Then I use this query to find which datafile is being hit the most:
    select count, file#, name
    from x$kcbfwait, v$datafile
    where indx + 1 = file#
    order by count desc;
    The query above returned:
    COUNT     FILE#     NAME
    473324     121     /xx/xx_ycm_tbs_03_01.dbf
    104179     120     /xx/xx_ycm_tbs_02_01.dbf
    93336     118     /xx/xx_idx_tbs_03_01.dbf
    93138     119     /xx/xx_idx_tbs_03_02.dbf
    80289     90     /xx/xx_datafile67.dbf
    64044     108     /xx/xx_ycm_tbs_01_01.dbf
    61485     41     /xx/xx_datafile25.dbf
    61103     21     /xx/xx_datafile8.dbf
    57329     114     /xx/xx_ycm_tbs_01_02.dbf
    29338     5     /xx/xx_datafile02.dbf
    29101     123     /xx/xx_idx_tbs_04_01.dbf
    file# 121 is in a tablespace with this only datafile and this tablespace hold only one table. file#120 is the same thing, it's in another tablespace and only one table in that tablespace.
    At the same time, i use TOP in Solaris I see iowait range between 5-25% during busy hour.

  • Catching an exception thrown from another thread

    I have a SocketServer that creates new threads to handle incoming clients. If one of the threads throw a SQLException is it possible to catch that exception in the SocketServer that created that thread.
    I tried implementing this code and I cannot get the server to catch an exception thrown in the thread. Are my assumptions correct?
    I was reading something about Thread Groups and implementing an uncoughtException() method, but this looked like overkill.
    Thanks for your time!
    Some Example code would be the following where the ClientThread will do a database query which could cause an SQLException. I'd like to catch that exception in my Socket Server
          try
                 new ClientThread( socketServer.accept() , host, connection ).start();
          catch( SQLException e )
                 System.out.println( "DataSource Connection Problem" );
                  e.printStackTrace();
          }

    hehe, why?
    The server's job is to listen for an incoming message from a client and pass it off to a thread to handle the client. Otherwise the server will have to block on that incoming port untill it has finished handling the client and usually there are many incoming clients continuously.
    The reason I would want to catch an exception in the server based on the SQLException thrown in the thread is because the SQLException is usually going to be due to the fact the datasource connection has become unavalable, or needs to be refreshed. This datasource connection is a private variable stored in the socket server. The SocketServer now needs to know that it has to refresh that datasource connection. I would normally try to use somesort of flag to set the variable but to throw another wrench into my dilemma, the SocketServer is actually its own thread. So I can't make any of these variables static, which means I can't have the thread call a method on teh socket server to change the status flag. :)
    I guess I need implement some sort of Listener that the thread can notify when a datasource connection goes down?
    Thanks for the help so far, I figured java would not want one thread to catch another thread's exceptions, but I just wanted to make sure.

  • Are you suppose to access UIView from another thread?

    A lot of UI events in my apps take place in another thread. So in my uivewcontroller, it catches a button click for example, it launches a NSThread with some parameter. The reason I decided to use a thread is because if the duration takes long the UI completely locks up. The thread then fetches for some result and access a pointer to a UIView (a UILabel for example) and update it's content.
    Now, is this model correct? I'm running in cases where setting the UILabel.text from the thread sometimes work, sometimes doesnt. I'm not sure how to debug. If I change the thread call to a standard method call (which blocks until results are ready) the text is updated correctly.
    Any hints?

    http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/ThreadS afetySummary/chapter950_section2.html

  • PreparedStatement.close() hangs, blocking finalization

    We encountered an incident on a production system with a class that would call PreparedStatement.close() on finalize(), and there was an instance where the jvm finalizer thread stalled on this the PreparedStatement.close() call, blocking garbage collection.
    The last sql statement run with the preparedstatement was most probably a select statement (we cannot determine for sure), and the OCI driver was used.
    While I realize it's not recommended to close PreparedStatements on finalize(), can I ask for some possible reasons why the close() call would stall? Would it be a database issue or a java issue?

    Can you do the close() in a PhantomReference? That might be a good alternative to using finalize(). These refs are rather obscure and most Java authors parrot the usual line about post-mortem cleanup, but if you dig deep enough you can find a few examples of its use (I think that there is Apache group source with an example).
    If you are running in a servlet, move the close() to the servlet destroy() method.
    The best solution is to use 10.2 implicit connection caching and close all your Connections immediatly after use in a finally block. Then close your DataSource in the destroy().

  • Start timer from another thread

    I am working on a project which will receive command from telnet and start a timer.
    In the sock function, I use form reference to call timer.start(), but timer control cannot start Tick event:
    Here is code for sock functin after receive the command:
     static void appServer_NewRequestReceived(AppSession session, StringRequestInfo requestInfo)
                switch (requestInfo.Key.ToUpper())
                    case ("START"):
                        session.Send(requestInfo.Body);
                        changetimer(1, requestInfo.Body);
    break;}}
    Here is the function to call timer start:
      static void changetimer(int action, string incomingmsg)
                //timer1.Start();
                Form1 frm = (Form1)Application.OpenForms["form1"];
                switch (action)
                    case 1:
                         frm.timer1.Start();
                         break;
                    case 2:
                        frm.timer1.Stop();
                        break;
    and this is timer tick :
    private void timer1_Tick(object sender, EventArgs e)
                TimeSpan result = TimeSpan.FromSeconds(second);
                string fromTimeString = result.ToString();
                label1.Text = fromTimeString;
                second = second + 1;

    You should start the timer on the UI thread. You could use the Invoke method to access a UI element from another thread:
    static void changetimer(int action, string incomingmsg)
    //timer1.Start();
    Form1 frm = (Form1)Application.OpenForms["form1"];
    switch (action)
    case 1:
    frm.Invoke(new Action(() => { frm.timer1.Start(); }));
    break;
    case 2:
    frm.Invoke(new Action(() => { frm.timer1.Stop(); }));
    break;
    Hope that helps.
    Please remember to close your threads by marking helpful posts as answer and please start a new thread if you have a new question.

  • Lappy wireless with iwl4965 issues .. yes another thread

    Another thread in the tonne I searched up and completely failed to find a solution to my problem in. Wish I could remember the ancient email I signed up for the forums ages ago with too =[
    Anyways... Problem: All activity drops in mere seconds upon first trying to connect to any site...
    I have the driver installed fine, along with wicd which has control of my wlan0 like it should, the scan of SSIDs turns up fine, I can connect to my network fine too.
    I can get an IP addy just fine, I can ping external IPs endlessly.
    I can resolve IPs it seems, I tried pacman with wget to make sure my IPs were being resolved properly, it always connects and gets the first few tarballs, then on one of them the speed (as reported by wget) drops from full speed to 0 over a few seconds, and it never picks up again, and fails to retrieve any more files.
    http sites are the same, it connects for a second, then is endlessly waiting.
    Would love to get this working, and I should point out I have no problems at all with my ethernet connection.
    Any ideas guys?

    i use the same driver as you guys for my 
    Intel Corporation Wireless WiFi Link 5100
    and "network manager" and have no problem whatsoever.
    To get my wifi working i had to copy the
    iwlwifi-4965-2.ucode
    file into "/lib/firmware".
    Try doing the same, might work

  • Killing an exec'ed process from another thread

    Hi all,
    I written an application that executes some external OS - processes. There is a dispatcher thread, that starts the execution threads for some jobs. Every execution thread creates a Processes by calling runtime.exec(), adds this object to a TreeMap ( member of the dispatcher ), creates two threads for reading the output of the process ( sdtout & stderr ) and calls p.waitFor(). From this moment this thread is blocked. After the process is done, the results will be processed by this thread etc. Now I want to go ahead and let the application user kill the process. For them I let the dispatcher - thread, that has also a reference to the executed process to call destroy of it if necessary during the execution thread is blocked by waitFor() and two output threads are reading stdout & stderr. The problem is however that destroy() - call from another thread doesn't kill the subprocess. The subprocess is running until it's done or terminated from out of jvm. Have you an idea or example?
    Thanks a lot & regards
    Alex

    >
    I know you have been discussing your problem is that
    you can't kill a "sleep" process. But just to be
    sure, I tested your description by one thread exec-ing
    a "not-sleep" program, and then another thread had no
    trouble killing it.
    I took your code and wrote a program around it such
    that
    Thread1 :
    - creates a Job (but not a "sleep" job); creates a
    JobMap ; puts Job in JobMap
    - starts Thread2 (passing it JobMap)
    - sleeps 15 seconds
    - calls Job.kill() (your method)
    Thread2 :
    - gets Job from JobMap
    - calls Job.execute() (your method)
    It's quick and dirty and sloppy, but it works. The
    result is when the kill takes place, the execute
    method (Thread2) wakes from its waitFor, and gets
    exitValue() = 1 for the Process.
    so,
    In order to kill the sleep process, which (according
    to BIJ) is not the Process that you have from exec
    call, maybe the only way to kill it is to get its PID
    an exec a "kill -9" on it, same as you said you had to
    do from the commandline. I don't know if you can get
    the PID, maybe you can get the exec-ed process to spit
    it onto stdout or stderr?
    (I am on win, not *nix, right now, so I am just
    throwing out a suggestion before bowing out of this
    discussion.)
    /MelHi Mel,
    yes, it should work right on windows because you created probably the shell by cmd /c or something like this. If you kill the cmd - process, everithing executed by the interpretter will be killed too. My application is running on Windows and unix. On unix I have to execute the process from a shell ( in my case it is the born shell ). The problem is however, that the born shell has another behaviour as cmd and doesn't die. Do you have an idea how to get the pid of the process started by sh without command line? To kill the processes from the command line is exactly what my customers do now. But they want to get "a better service" ...:-)
    Regards
    Alex

  • Keymapping (follow up from another thread)

    To follow up on another thread, I checked out the keymappings and found most of what I was looking for.
    Only a couple of things I miss:
    1. SHIFT + TAB doesn't pull the text back with it if the text is not selected. I am convised most editors do this and I keep find myself trying to do it in JDev and it doesn't work, and then I go in a huff.
    2. Ctrl+K, Ctrl+L to perform a word match forwards or backwards, based purely on text in the document, ie. not syntax/context sensitive. This was one of my most used/most time saved features in Netbeans.

    Hi,
    don't understand what 1) is supposed to do. Can you explain this further? Winword and TextPad behave differently. I tried NetBeans and shift+tab is doing nothing.
    For 2) Is it the same as
    pressing ctrl+f to enter a search string and then continuing with F3 for forward matches and shift+F3 for backward matches? If you select a string before pressing ctrl+f then this string is added to the search list.
    If yes, then you can change the key mapping in Tools-->Preferences --> Accelerators to the keyboard combination you are most familiar with (look for "find").
    Frank

  • How to use ImageContr​ol on another thread out main

    Hi All,
    I'm looking to use ImageControl (ImageControl.fp) on another thread out main thread 
    In my second thread i try to update image but i have a error (This panel operation can be performed (if a top-level panel) only in the thread in which the panel was created, or (if a child panel) only in the thread in which the top-level parent panel was created.)
    Here my code
    Main thread :
    ImageControl_ConvertFromDecoration (panelHandle, PANEL_IMAGECTRL, 0);
    ImageControl_SetZoomToFit (panelHandle, PANEL_IMAGECTRL, 1);
    ImageControl_SetAttribute (panelHandle, PANEL_IMAGECTRL, ATTR_IMAGECTRL_SHOW_SCROLLBARS, 0);
     hdleThread = CreateThread(NULL, 0,  (LPTHREAD_START_ROUTINE) ThreadTest,  NULL,  0, &idThread);
    Secand thread :
    int ThreadTest (void * data)
    ImageControl_SetZoomToFit (panelHandle, PANEL_IMAGECTRL, 1);
    iIdError  =    ImageControl_SetAttribute (panelHandle, PANEL_IMAGECTRL, ATTR_IMAGECTRL_IMAGE, imageToDisplay);
    // iIdError  = -129
    Could you help me ?
    Thankyou

    many thanks.  I should have thought of the need for using the Target Display Mode. 
    tony

  • How can I pass an exception from one thread to another thread

    If I create a new class, that will extends the class Thread, the methode run() can not be use with the statement Throws Exeption .
    The question now: Is there any possibility to pass an exception from one thread to another thread?
    Thx.

    It really depends on what you want to do with your exception. Is there some sort of global handler that will process the exceptions in some meaningful way? Unless you have that, there's not much point in throwing an exception in a thread, unless you simply want the stack trace generated.
    Presuming that you have a global handler that can catch exceptions, nest your Exception subclass inside a RuntimeException:
    public class NestedRuntimeException extends RuntimeException
        private final m_nestedException;
        public NestedRuntimeException(final Exception originalException)
            super("An exception occurred with message: " + originalException.getMessage());
            m_nestedException;
        public Exception getNestedException()
            return m_nestedException;
    }Your global handler can catch the NestedRuntimeException or be supplied it to process by the thread group.

Maybe you are looking for

  • What format do I ned to make my external hard drives to enable them to work with both Mac and PC?

    I'd like to format several external hrd drives to work with both my Mac Book Pro and a PC in the house.  Disk utility says ok for esFat to wrok with both but techies say format as FAT.  Also, does size of external have an influence on the formatting

  • 4.4Kitkat Wishlist for new update

    I think some of Z1 users experience 4.4 and i would like to ask them to put your wishes for a better change for the next update. I now sony is listening to there consumers. I would like to see more settings to change like for messaging, screen bright

  • Radio Shack USB Link-Networking Cable...

    I have a special USB cable, subject as above, and, though I wish I could post one, I don't have a photo and there's no link on the web, I reckon, to a photo. Anyway, this cable allows me to connect two PeeCees together, be they running Windoze 2000,

  • Forgot restriction password

    i got my iphone back from repair and i was going to restore the pictures from the icloud backup so i have to reset But i forgot my restriction password and have tried 8 failed pass code attempt then i found another way But when i connect it to my com

  • APEX username and password

    Hi, I have ORACLE XE with APEX 3.1. I have had no problem with the setup until today when I accessed the image folder via http://127.0.0.1:8080/i now if I try and log in before I even get the home page with workspace, username and password I get a wi