Interrupting a Thread thats blocking for I/O

OK, here is the problem. I need to interrrupt a thread that is blocking on I/O. The run method of my thread looks something like this...
run(){
while(connected){
try{
recieved = in.readLine();
// do something with recieved data
} catch(InterruptedIOException e){
// do something
} catch(SocketException e){
// do something else
} catch(IOException e){
// do some more of something else
I also have a fuction like this...
private void stop(){
connected = false;
myThread.interrupt();
None of this appears to be working. The interrup method runs but no exceptions are thrown. I need to be able to tell the thread to stop blocking for I/O an stop running. Is there some other way, or am I on the right track and its just coded wrong? Any help would be great.

There are 2 reasons for your code to mallfunction:
1. You should catch an InterruptedException first (this is thrown at Thread.interrupt()), not InterruptedIOException (which comes from the Socket).
2. For ensuring your thread.stop, you have messed up 2 different techniques:
Setting the connected = false in your stop method could make you jump out your whole while loop, so you will never reach you code in the catch blocks.
You also call myThread.interrupt() so if you stop() method occurs in the middle of processing, you will end-up in you catch(InterruptedException) block.
So there are 2 distinct reactions that may occur at your stop(), depending on them moment when it is called, which doesn't look so good.
Depending on how you want your code to behave (to end-up in the catch block or after the whole while loop) use just one of the instructions in your stop() method. It is recomended that you keep 'connected = false', but then you have to watch out the blocking IORead :(

Similar Messages

  • Testcase for error - "Unable to allocate thread control block"

    Hello,
    The down-below code throws the error message:
    db_stat: Unable to allocate thread control block
    BDB: 4.8, OS: Ubuntu 9.10
    Thanks
    #include <stdlib.h>
    #include <sys/ipc.h>
    #include <db.h>
    #define DIRECTORY "/tmp/db"
    int main()
    // open environment
    DB_ENV *handle;
    int status = db_env_create( &handle, 0 );
    status = handle->set_cachesize( handle, 0, 32*1024*1024, 0 );
    status = handle->set_thread_count( handle, 0x100 );
    key_t key = ftok( DIRECTORY, 'M' );
    handle->set_shm_key( handle, key );
    u_int32_t flags = DB_CREATE | DB_INIT_MPOOL | DB_INIT_TXN | DB_INIT_LOCK | DB_INIT_LOG | DB_SYSTEM_MEM;
    status = handle->open( handle, DIRECTORY, flags, 0644 );
    if( status != 0 )
    exit( 1 );
    // raise error
    chdir( DIRECTORY );
    for( int i=0; i < 0x1000; ++i )
    system( "db_stat -e | grep process/thread | wc" );
    return 0;
    }

    Hello,
    I am still looking into this, but upon closer examination here is the situation, basically as reported.
    The test calls set_thread_count which sizes the memory. In __env_attach(), (dbenv->thr_max is used to size the region. So you are correct, the higher the value used in set_thread_count, the larger the size of the region will be. Eventually that memory will be depleted, and __env_alloc_size() returns ENOMEM, after multiple calls to system(db_stat). __env_alloc_free() is not called. This is the part I am still investigating.
    The test uses system to fork a separate processes for db_stat and the failing stack is:
    lt-db_stat: assert failure: ../dist/../env/env_failchk.c/426: "ret == 0"
    lt-db_stat: __os_stack+0x2b
    lt-db_stat: __os_abort+0x1d
    lt-db_stat: __db_assert+0x47
    lt-db_stat: __env_set_state+0x53c
    lt-db_stat: __env_attach_regions+0x38b
    lt-db_stat: __env_open+0x154
    lt-db_stat: __env_open_pp+0x334
    lt-db_stat: lt-db_stat
    So db_stat is opening an environment, attaching to its region, and then __env_set_state() calls __env_alloc(). It is __env_alloc() which fails with ENOMEM after some point when there is no more space to be allocated from the shared region. And I'm still looking into that space would be returned to the shared region.
    Thanks,
    Sandra

  • How to specify for JVM the stack for ONE specific thread that invokes JNI

    Hello all!
    I'm 2 days now looking for a solution in several forums but even in Sun Java Forums nobody was able to come up with a solution. If you know a better forum to place it, please let me know.
    Description:
    I have an application that launches several threads of different types. One of them is quite specific and run a critical JNI C++ process. The remaining ones are just for controling of other stuff... When I call the application by the command line
    java -classpath ... -Xss20m -Djava.library.path ... pack.subpack.myApp
    the application usually crashes: My computer has 256MB RAM of memory that vanish in seconds and causes an OutOfMemoryException
    Sometimes the application works properly, but sometimes the memory usage goes up fast until a general crash.
    What I believe that is going on:
    When we declare -Xss20m, I undestand that for each thread the JVM will attemp to allocate more 20MB, and if I have 10 threads, it goes up to 200MB and so on; however I'd like to have 20MB just for my critical process (that is called in one specific thread) and not for any thread.
    If I try to reduce -Xss parameter to, let's say 10MB, my C++ process overflow the JVM stack for the thread.
    So, does any body have know how to solve it? Please... I need experts help!
    Thanks a lot,
    Calegari

    There we go...
    I have this class:
    package calegari.automata;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2003</p>
    * <p>Company: </p>
    * @author Aur�lio Calegari
    * @version 1.0
    public class Native {
    * Parameters:
    * individuals --> All binary individual (AC rule)
    * indivLength --> number of infividuals
    * numEval --> number of RIs
    * generateUniform --> Uniform distribution of density
    * seed --> seed for current generation
    public native double[] AutomataIterator(int[][] individuals,
    int indvLength,
    int numEval,
    boolean generateUniform,
    long seed
    static {
    System.loadLibrary("Native");
    public Native() {
    Then, running
    javah -classpath ... calegari.automata.Native
    I'll get the following .h
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include "jni.h"
    /* Header for class calegari_automata_Native */
    #ifndef Includedcalegari_automata_Native
    #define Includedcalegari_automata_Native
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: calegari_automata_Native
    * Method: AutomataIterator
    * Signature: ([[IIIZJ)[D
    JNIEXPORT jdoubleArray JNICALL
    Java_calegari_automata_Native_AutomataIterator___3_3IIIZJ
    (JNIEnv *, jobject, jobjectArray, jint, jint, jboolean, jlong);
    #ifdef __cplusplus
    #endif
    #endif
    Next, I built my cpp file which is right bellow
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    #include "jni.h"
    #include "calegari_automata_Native.h"
    #include "util.h"
    double IndividualEvaluator(long rule[], int automataCells[][149], int numInit1s[],
    int numOfACs, int numEvaluations);
    char getNext(char simb);
    JNIEXPORT jdoubleArray JNICALL
    Java_calegari_automata_Native_AutomataIterator___3_3IIIZJ
    (JNIEnv *env, jobject jobj, jobjectArray indiv, jint length, jint numEval,
         jboolean isUniform, jlong seed)
    printf("Native JVM call for C++ critical block: Started \a[-]");
    int ACs[10000][149]; //Will be filled with 100000 Initial states of a cellular automata
    int numIndiv = length;
    int numOfACs = numEval;
    //Dencity of each Initial state of cellular automata
    int num1sRIs[10000];
    //response
    double resp[1000];
    //set seed
    srand((unsigned int) seed);
    //generate Cellular automata states
    //Uniform generation
    if(isUniform)
    for(int i=0;i<numEval;i++)
    int num1s;
    num1s=0;
    for(int j=0;j<149;j++)
    ACs[i][j] = ((rand()%numEval)<i+1?0:1);
    if(ACs[i][j]==1) num1s++;
    num1sRIs[i] = num1s;
    printf(" %d ",num1s);
    else //not uniform generation
    for(int i=0;i<numEval;i++)
    int num1s;
    num1s=0;
    for(int j=0;j<149;j++)
    ACs[i][j] = rand()%2;
    if(ACs[i][j]==1) num1s++;
    num1sRIs[i] = num1s;
    //load individuals and start the critical method
    char simb = '-';
    for(int i=0;i<numIndiv;i++)
    jintArray oneDim = (jintArray) env->GetObjectArrayElement(indiv, i);
    jint *indiv=env->GetIntArrayElements(oneDim, 0);
    simb = getNext(simb);
    printf("\b\b%c]",simb);
    resp[i] = IndividualEvaluator(indiv,ACs,num1sRIs,numOfACs,300);
    jdoubleArray retApts;
    retApts = env->NewDoubleArray(numIndiv);
    env->SetDoubleArrayRegion((jdoubleArray)retApts,(jsize)0,numIndiv,(jdouble *)resp);
    printf("\nReturning to Java plataform: Completed\a\a\n");
    return retApts;
    char getNext(char simb)
    if(simb=='-') simb = '\\';
    else if(simb=='\\') simb = '|';
    else if(simb=='|') simb = '/';
    else if(simb=='/') simb = '-';
    return simb;
    Then it works fine since we declare the size of the stack to JVM, however, if we don't... We get a crash!
    Any idea?
    Thanks

  • Timer that will interrupt a thread

    How do I create a timer that will interrupt a thread?
    I need to put this timer inside the thread, and I should be able to manipulate the time.
    I have managed to create an inner class that act as the timer. But, I can't make the timer to interrupt the main thread.
    Can anyone help me? Is there any simpler way to do this?

    See Thread.interrupt()
    If you call this while a thread has called sleep() and is waiting, this should then throw an InterruptedException
    BTW, in the case where you have a thread that reading from a socket / inputstream, and blocked on read(), the way that I always use to unblock my thread is to simply close the stream, which generates an IOException and unblocks the thread.
    ...And BTW Thread.stop() has never been implemented and does nothing!
    Edited by: tjacobs01 on Jan 3, 2008 6:09 AM

  • Purchase ledger invoices that are blocked for quality inspection.

    Purchase ledger invoices that are blocked for quality inspection.When invoices are keyed against a stock item that is required to be checked for quality the invoice automatically blocks. Once the check has been carried out and the batch has been released the invoice should automatically release for payment according to terms, however this is not happening.I checked MSC3N,where batch is in unrestricted and status released.Still in material document shows batch in QI.
    Can any one what is the problem.

    Hi
    check in MMBE where the material is lying under the batch .Is it under QI or Unrestricted.
    from QI07 you can put it into Unrestricted or take the UD of lot if generated.
    please revert back
    Regards
    Sujit

  • How do I upgrade Adobe reader - currentlyevery time I try to download a PDf file on my macpro I get a grey screen  and a dialog box that says adobe reader is blocked for this website...

    Help - a couple of weeks ago I tried up upgrade adobe reader but it never completed loading as far as I can find / that night would never finish
    ( how would I know , where would I check?)
    now every time I need to download a PDF file ( dental claim forms tonight) I get a grey screen with a dialog box that says Adobe reader blocked for this site
    and that happens on any site where I am trying to download a PDF…?

    What is your operating system?  Reader version?  Downloading from what browser?

  • HT2589 My account is blocked out. I registered my account for Russia because there was no that option for Ukraine. And now I can't do any purchasing, because apple store want's another payment option. What should I do? Ps my friends here has such a proble

    My account is blocked out. I registered my account for Russia because there was no that option for Ukraine. And now I can't do any purchasing, because apple store want's another payment option. What should I do? I have many apps on my account but I can't do even updating.  Ps my friends here has such a problem too

    Ukraine is there. It's been there for a while. I even see it now.

  • Is there a way for this community, to make a suggestion to Apple to include blocking a specific contact number calls and messages just as other phones provide that feature for their users.

    Is there a way for this community, to make a suggestion to Apple to include blocking a specific contact number calls and messages just as other phones provide that feature for their users.

    No phone provides true call blocking. At best, they provide call diversion. Essentially, the call is answered and disconnected automatically. If I recall, Apple is adding call diversion features in iOS 7.
    Best of luck.

  • I have lupus and am extremely photo sensitive.  I have a filter on my laptop screen that blocks out 99% of UVA and UVB rays (otherwise I have very bad flareups).  Does anyone know if there is a similar filter for the iPad?

    I have lupus and am extremely photo sensitive.  I have a filter on my laptop screen that blocks out 99% of UVA and UVB rays (otherwise I have very bad flareups).  Does anyone know if there is a similar filter for the iPad? I have searched, but still have not found anything.

    Here's one http://www.mobilefun.com/28385-martin-fields-screen-protector-twin-pack---apple- ipad-3-ipad-2.htm
    There are others if you do a Google search using ipad screen protector block uv rays
     Cheers, Tom

  • I use Safari as my browser. When on a site and I click on a PDF file I get a black screen and a notice that "Adobe Reader blocked for this website". However, this does not happen if I use Firefox.

    I use Safari as my browser. When on a site and I click on a PDF file I get a black screen and a notice that "Adobe Reader blocked for this website". However, this does not happen if I use Firefox.

    Back up all data before making any changes. Please take each of the following steps until the problem is resolved.
    Step 1
    If Adobe Reader or Acrobat is installed, and the problem is just that you can't print PDF's displayed in Safari, you may be able to print by moving the cursor to the the bottom edge of the page, somewhere near the middle. A black toolbar may appear under the cursor. Click the printer icon.
    Step 2
    There should be a setting in its preferences of the Adobe application such as Display PDF in Browser. I don't use those applications myself, so I can't be more precise. Deselect that setting, if it's selected.
    Step 3
    If you get a message such as ""Adobe Reader blocked for this website," then from the Safari menu bar, select
    Safari ▹ Preferences... ▹ Security
    and check the box marked
    Allow Plug-ins
    Then click
    Manage Website Settings...
    and make any required changes to the security settings for the Adobe PDF plugin.
    Step 4
    Triple-click anywhere in the line of text below on this page to select it, the copy the selected text to the Clipboard by pressing the key combination command-C:
    /Library/Internet Plug-ins
    In the Finder, select
    Go ▹ Go to Folder
    from the menu bar, or press the key combination shift-command-G. Paste into the text box that opens (command-V), then press return.
    From the folder that opens, move to the Trash any items that have "Adobe" or “PDF” in the name. You may be prompted for your login password. Then quit and relaunch Safari.
    Step 5
    The "Silverlight" web plugin distributed by Microsoft can interfere with PDF display in Safari, so you may need to remove it, if it's present. The same goes for a plugin called "iGetter," and perhaps others — I don't have a complete list. Don't remove Silverlight if you use the "Netflix" video-streaming service.
    Step 6
    Do as in Step 3 with this line:
    ~/Library/Internet Plug-ins
    If you don’t like the results of this procedure, restore the items from the backup you made before you started. Relaunch Safari.

  • Im trying to log into a website. When I log in, a message appears that the website has been blocked for my safety. Allow button appears but I cant click on it

    I type a website address and go to that website. I try to log into website and message appears on top screen that I am blocked out for my safety. An Allow button appears, but when I click on it, I am still not allowed to log into website. How can I be allowed to log into website?

    Thank you for responding madperson. No, the message didnt say connection was untrusted, just "blocked for my safety." Allow button quickly appeared/disappeared, I couldnt click on it. This is a webpage in which I am a member & needed to log in my user & password. I deleted my cookies & cache and went to internet options & where you can choose which websites you dont want cookies, I entered website address, clicked OK & then was able to log into website. It was frustrating, but now solved.
    Thank you for your help, madperson, appreciate it. Madison2013

  • Is there a way to read text messages from the past in a thread that has been ongoing for months?

    Is there a way to view/recover messages from months ago in a thread that has been ongoing? The messages are not deleted. If i just keep "loading new messages" a) it will take all day, I've tried, and b) it freezes on me.

    Try the computer apps PhoneView (Mac) or TouchCopy (Mac & PC):
    http://www.ecamm.com/mac/phoneview/
    http://www.wideanglesoftware.com/touchcopy/index.php
    Both will allow you to archive your text messages to your computer and read them easily.

  • Threads and blocking i/o

    background i am building a multi-cliented server based on the model of one thread per client. client threads wait on a BufferedReader in the run() method for data over the network and take the appropriate action based on the input.
    problem a client thread needs in certains circumstances to kill the thread of another client. since the run() method loops on the blocking input of BufferedReader, any flag or call to interrupt() will not be evaluated until the BufferedReader unblocks. this is bad since it means that the client who is to be killed will not return from run() until the client app talking to the thread sends some data to unblock BufferedReader. the result is a potential dos attack against this server. bad stuff.
    example the current situation: client app one connects to the server spawning Thread-1. client app two connects to the server spawning Thread-2. app two triggers killSomeClient() on Thread-1. Thread-1 continues to linger until client app 1 transmits data to the server, whereupon Thread-1 dies.
    example the required functionality: app one connects to Thread-1. app two connects to Thread-2. app two triggers killSomeClient() on Thread-1. Thread-1 returns from the run() loop and the thread dies immediately.
    what i've tried well, obviously, stop() and destroy() are what i really want... but that's not an option. have tried setting a flag in the while loop to be set by killSomeClient() (ie while(keepRunning && (inputFromClient = in.readLine()) != null) ). have tried interrupt() in the same manner.
    potential solutions i can think of a replacement for stop() or some effective non-blocking read allowing me to loop around the reader, grabbing one char at a time and continuing the loop even if the queue is empty.
    the code example this is a very pared-down version of the code showing only the material necessary for this example (better for readability!). aside from this issue, the application runs.
    someClient
    public class someClient{
        private Socket socket;
        private BufferedReader in;
        private String inputFromClient;
        someClient(Socket socket){
            this.socket = socket;
            this.in = new BufferedReader(new InputStreamReader(theSocket.getInputStream()));
        public void run(){
            try{
                // waits on blocking input
                while((inputFromClient = in.readLine()) != null){
                    System.out.println(inputFromClient);
            }catch(Exception e){}
        public void killSomeClient(someClient killme){
            // help!!
    someServer
    public class someServer{
        private ServerSocket ss;
        public someServer(){
            ss = new ServerSocket(9999);
        public startServer{
            Socket socket = ss.accept();
            someClient client = new someClient(socket);
            client.start();
    }

    problem a client thread needs in certains
    circumstances to kill the thread of another client.
    since the run() method loops on the blocking input of
    BufferedReader, any flag or call to interrupt() will
    not be evaluated until the BufferedReader unblocks.In general, the best approach to terminating a blocking operation is to invalidate the object on which that operation depends. In your case, closing the socket will terminate the read().
    The following is a rather lengthy piece of code that's actually been tested :-)
    import java.io.*;
    import java.net.*;
    public class SocketStopper
        private final static int  PORTNUM = 10000;
        public static void main( String argv[] )
        throws Exception
            System.err.println("Starting server");
            Server server = new Server();
            (new Thread(server)).start();
            Thread.sleep(2000);
            System.err.println("Starting client");
            Client client = new Client();
            (new Thread(client)).start();
            Thread.sleep(2000);
            System.err.println("About to close server socket");
            server.closeSocket();
            Thread.sleep(2000);
            System.err.println("About to exit");
            System.exit(0);
        /** This object establishes a connection to the server port and then
         *  sleeps for 10 minutes without writing anything. This should cause
         *  the reader to block for input.
        public static class Client
        implements Runnable
            public void run()
                try
                    Socket sock = new Socket(InetAddress.getLocalHost(), PORTNUM);
                    System.err.println("Client established connection");
                catch (Exception e)
                    System.err.println("Client unable to establish connection: " + e);
                    return;
                try
                    Thread.sleep(10 * 60000L);
                catch (InterruptedException ignored)
        /** This object sets up a server socket. It accepts the first connection
         *  from that socket and attempts to read from it, which should block.
        public static class Server
        implements Runnable
            private Socket _sock;
            public void run()
                try
                    ServerSocket srv = new ServerSocket(PORTNUM);
                    _sock = srv.accept();
                    System.err.println("Server accepted connection");
                catch (Exception e)
                    System.err.println("Server unable to receive connection: " + e);
                    return;
                try
                    _sock.getInputStream().read();
                    System.err.println("read() completed normally");
                catch (IOException e)
                    System.err.println("read() terminated with exception: " + e);
            public void closeSocket()
                try
                    _sock.close();
                catch (IOException ignored)
    }

  • Interrupting a Thread in a Remote Object?

    HI,
    I am trying to get some thread synchronization to happen between a client and a remote RMI object. Essentially what I am trying to accomplish, is that if I interrupt a call on a blocking method in the remote object, I want the thread to throw the InterruptException. For example, the following code represents what I am trying to accomplish:
    package bca.test.rmi;
    import java.rmi.Naming;
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    import java.rmi.server.UnicastRemoteObject;
    public class InterruptThreadApp {
    RemoteBlockingObjectInt remote = null;
    public static void main(String[] args) throws Exception {
    //Create the remote object
    RemoteBlockingObject obj = new RemoteBlockingObject();
    //bind it to the registry
    Naming.rebind("rmi://localhost/blocking", obj);
    //start the client, or the thread which will access the blocking call remotely
    InterruptThreadApp app = new InterruptThreadApp();
    Thread blocking = null;
    //wait for the thread to start
    synchronized ( app ) {
    blocking = app.startClient();
    app.wait();
    Thread.sleep(2000);
    //now interrupt the thread (note: the remote object should be blocking in
    //the blockingMethod().. this should produce an InterruptException?
    blocking.interrupt();
    public Thread startClient() {
    Thread t = new Thread("Client") {
    public void run() {
    try {
    //get a handle to the stub
    remote = (RemoteBlockingObjectInt) Naming.lookup("rmi://localhost/blocking");
    //now make a call to the blocking method, but first wake up the client
    synchronized ( InterruptThreadApp.this ) {
    InterruptThreadApp.this.notify();
    //now make the blocking call
    remote.blockingMethod();
    catch (InterruptedException e) {
    System.out.println("WooHoo! This is what we want! But it never gets thrown :(");
    catch (Exception e) {
    e.printStackTrace();
    t.start();
    return t;
    package bca.test.rmi;
    import java.rmi.server.UnicastRemoteObject;
    import java.rmi.RemoteException;
    import java.rmi.Remote;
    public class RemoteBlockingObject extends UnicastRemoteObject implements RemoteBlockingObjectInt {
    Object obj = new Object();
    public RemoteBlockingObject() throws RemoteException {
    super();
    public void blockingMethod() throws RemoteException, InterruptedException {
    synchronized (obj) {
    System.out.println("About to block.. so we can be interrupted later");
    obj.wait();
    interface RemoteBlockingObjectInt extends Remote {
    public void blockingMethod() throws RemoteException, InterruptedException;
    When I make a call to "remote.blockingMethod()", it blocks in the remote object (buy just "wait" ing). I want to interrupt this thread, by issuing an Thread.interrupt(). When I do so (I call "blocking.interrupt()"), nothing happens... no exception is thrown.. it just silently fails.
    Ok, so I suppose that we can not interrupt a remote thread.. that is fine. But what if I want to interrupt the RMI thread making the remote call? I don't want it to block forever. How can I "cancel" the remote call?
    Ideally, I would like the remote.blockingMethod() call to throw an InterruptException when I issue an "interrupt()" on the blocking thread. Any suggestions on how I might accomplish this?
    Thanks,
    Bryan

    While you can interrupt the RMI call, you cannot stop the active processing. That is, you cannot force a thread to stop (see the Java API documentation on Thread.stop().)
    Since the Client RMI call is a waiting thread, you need another Client thread to do a secondary RMI call. The trick is to have the new RMI endpoint connection thread on the RMI Server interrupt the original RMI endpoint connection thread.
    The only way you can interrupt an RMI call is to have the endpoint connection thread that runs on the RMI Server be aware that the user may wish to interrupt it.
    The best means of interruption is for the endpoint connection thread to use "worker threads". The endpoint connection thread waits for the workers to finish and is interruptible by both the workers and other endpoint connection threads.
    Another means of interruption is for the endpoint connection thread to segment the task into units of work and check for an interruption between those units of work.
    There are two ways I've done RMI call interruption.
    One is for the Client to pass a unique id (UID -- that uniquely identifies the request) to the Server with the original call. When the Client wishes to interrupt the original call, using the separate thread, it does a new RMI call to the Server passing the UID.
    The new endpoint connection thread, using the UID, interrupts the original endpoint connection thread.
    The major problem with this is the unique id. It absolutely, positively must be unique. Otherwise you run the risk of Client_A purging Client_B's request.
    The second method requires callback. If your Client is behind a firewall then RMI callback is near impossible. In such a case you must come up with a way for the Server to call the Client that is secure (the firewall problem.)
    The Client must export a remote object and pass that remote object to the Server with the original call.
    The endpoint connection thread recognizes the remote object and does a call back to the Client passing information that uniquely identifies itself (UID). Since the Server generates the UID, it can guarantee uniqueness.
    The Client callback implementation runs as a separate thread since the Client is in fact an RMI Server itself (when it did the export.) The Client must save the UID. The Client must start a new thread for the interrupt procedure or inform a waiting thread that the Server called back.
    Just like method one, above, when the Client wishes to interrupt the original call, using the separate thread, it does a new RMI call to the Server passing the UID.
    The new endpoint connection thread, using the UID, interrupts the original endpoint connection thread. Simple.
    For an academic example using call back go over to Jini.org. They have an example called "Cancellation" at:
    http://starterkit-examples.jini.org/
    For a professional, open source implementation of both these methods go over to CoopSoft.com. The Tymeac (Java) projects support canceling both waiting and autonomous requests at:
    http://www.coopsoft.com/JavaProduct.html

  • Db_checkpoint: Unable to allocate thread control block

    Hello,
    Every second day BDB 4.8 runs out of cache memory (size = 512MB).
    We have 10 static worker processes (no segfaults) and one
    db_checkpoint-process (checkpoints once a minute and exists).
    We use only DB_WRITE_NOSYNC
    After two days the db_checkpoint-process reports:
    db_checkpoint: Unable to allocate thread control block
    As soon as this error apears, I can neither checkpoint nor
    db_recover.
    Is there any chance (or a patch) to track down the memory leak?
    Thanks

    Hi Sandra,
    It happened again one hour ago. I had hardly problems with BDB 4.6
    Down below you will find a current "db_stat -e"
    We have 10 workers with persistent db-connection and once a minute
    a cronjob starts a checkpoint, then the cron-process exists.
    Every second day (40 to 48 hours) the checkpoint-process can't connect
    to the database and "db_checkpoint -1" says:
    db_checkpoint: Unable to allocate thread control block
    A normal "db_recover" would corrupt the database, I had to recover
    catastrophic.
    For sure the cache is not to small (512 MB, all database files: 1,3 GB)
    Thanks
    Markus
    Mon Nov 30 17:32:44 2009 Local time
    0x120897 Magic number
    0 Panic value
    4.8.24 Environment version
    9 Btree version
    9 Hash version
    1 Lock version
    15 Log version
    4 Queue version
    2 Sequence version
    1 Txn version
    Mon Nov 30 16:31:06 2009 Creation time
    0x9d316701 Environment ID
    2 Primary region allocation and reference count mutex [0/360 0% !Own]
    11 References
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Thread tracking information
    75 Thread blocks allocated
    4096 Thread allocation threshold
    521 Thread hash buckets
    Thread status blocks:
    process/thread 5055/3086948768: out
    process/thread 5686/3086850464: out
    [...snip...]
    process/thread 6056/3086653856: out
    process/thread 6087/3086649760: out
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    0x40988 Log magic number
    15 Log version number
    16MB Log record cache size
    0 Log file mode
    10Mb Current log file size
    370618 Records entered into the log
    370MB 354KB 853B Log bytes written
    4MB 466KB 1001B Log bytes written since last checkpoint
    17691 Total log file I/O writes
    0 Total log file I/O writes due to overflow
    198 Total log file flushes
    665 Total log file I/O reads
    1786 Current log file number
    8303086 Current log file offset
    1786 On-disk log file number
    3630597 On-disk log file offset
    1 Maximum commits in a log flush
    1 Minimum commits in a log flush
    17MB Log region size
    9 The number of region locks that required waiting (0%)
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    5387 Last allocated locker ID
    0x7fffffff Current maximum unused locker ID
    9 Number of lock modes
    131072 Maximum number of locks possible
    131072 Maximum number of lockers possible
    131072 Maximum number of lock objects possible
    30 Number of lock object partitions
    622 Number of current locks
    797 Maximum number of locks at any one time
    13 Maximum number of locks in any one bucket
    0 Maximum number of locks stolen by for an empty partition
    0 Maximum number of locks stolen for any one partition
    632 Number of current lockers
    708 Maximum number of lockers at any one time
    69 Number of current lock objects
    160 Maximum number of lock objects at any one time
    2 Maximum number of lock objects in any one bucket
    0 Maximum number of objects stolen by for an empty partition
    0 Maximum number of objects stolen for any one partition
    13M Total number of locks requested (13372706)
    13M Total number of locks released (13372083)
    0 Total number of locks upgraded
    5313 Total number of locks downgraded
    9 Lock requests not available due to conflicts, for which we waited
    1 Lock requests not available due to conflicts, for which we did not wait
    0 Number of deadlocks
    60M Lock timeout value (60000000)
    0 Number of locks that have timed out
    60M Transaction timeout value (60000000)
    0 Number of transactions that have timed out
    66MB 904KB The size of the lock region
    2141 The number of partition locks that required waiting (0%)
    465 The maximum number of times any partition lock was waited for (0%)
    0 The number of object queue operations that required waiting (0%)
    3 The number of locker allocations that required waiting (0%)
    0 The number of region locks that required waiting (0%)
    2 Maximum hash bucket length
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    320MB 1KB 604B Total cache size
    1 Number of caches
    1 Maximum number of caches
    320MB 8KB Pool individual cache size
    0 Maximum memory-mapped file size
    0 Maximum open file descriptors
    0 Maximum sequential buffer writes
    0 Sleep after writing maximum sequential buffers
    0 Requested pages mapped into the process' address space
    17M Requested pages found in the cache (99%)
    71264 Requested pages not found in the cache
    67 Pages created in the cache
    71264 Pages read into the cache
    17944 Pages written from the cache to the backing file
    0 Clean pages forced from the cache
    0 Dirty pages forced from the cache
    0 Dirty pages written by trickle-sync thread
    71298 Current total page count
    71014 Current clean page count
    284 Current dirty page count
    32771 Number of hash buckets used for page location
    4096 Assumed page size used
    16M Total number of times hash chains searched for a page (16751183)
    8 The longest hash chain searched for a page
    39M Total number of hash chain entries checked for page (39437498)
    0 The number of hash bucket locks that required waiting (0%)
    0 The maximum number of times any hash bucket lock was waited for (0%)
    7 The number of region locks that required waiting (0%)
    0 The number of buffers frozen
    0 The number of buffers thawed
    0 The number of frozen buffers freed
    71627 The number of page allocations
    0 The number of hash buckets examined during allocations
    0 The maximum number of hash buckets examined for an allocation
    0 The number of pages examined during allocations
    0 The max number of pages examined for an allocation
    0 Threads waited on page I/O
    0 The number of times a sync is interrupted
    Pool File: article.db
    4096 Page size
    0 Requested pages mapped into the process' address space
    1868517 Requested pages found in the cache (99%)
    13311 Requested pages not found in the cache
    0 Pages created in the cache
    13311 Pages read into the cache
    3428 Pages written from the cache to the backing file
    [...snip...]
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    1786/3630541 File/offset for last checkpoint LSN
    Mon Nov 30 17:32:01 2009 Checkpoint timestamp
    0x8000675a Last transaction ID allocated
    4096 Maximum number of active transactions configured
    0 Active transactions
    3 Maximum active transactions
    26458 Number of transactions begun
    0 Number of transactions aborted
    26458 Number of transactions committed
    0 Snapshot transactions
    0 Maximum snapshot transactions
    0 Number of transactions restored
    1MB 192KB Transaction region size
    0 The number of region locks that required waiting (0%)
    Active transactions:
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    31MB 32KB Mutex region size
    3 The number of region locks that required waiting (0%)
    4 Mutex alignment
    150 Mutex test-and-set spins
    254163 Mutex total count
    149165 Mutex free count
    104998 Mutex in-use count
    104998 Mutex maximum in-use count
    Mutex counts
    149165 Unallocated
    1 env region
    33 lock region
    797 logical lock
    1 log filename
    1 log flush
    1 log region
    74 mpoolfile handle
    71298 mpool buffer
    17 mpool file bucket
    32771 mpool hash bucket
    1 mpool region
    1 mutex region
    1 transaction checkpoint
    1 txn region

Maybe you are looking for

  • Adobe InDesign often crashed

    Hello, Issues with Indesign CS6 crashing 3-4weeks after fresh install. Version: 8.0.2 ran all the update in adobe/indesign, even fresh install of Windows a few time. System Information: Windows 7 Enterprise 64bit 6GB RAM CPU i5 3.20GHz Pulled the cra

  • Broadcast live to android browser

    Hello i have a web internet live cams aplication and i am using adobe media server 5 i succeed to broadcast http live from web cam to web browser on apple devices using this url: http://localhost/hds-live/livepkgr/_definst_/liveevent/livestream.f4m m

  • Upgrading a wlc 5508 from 7.0.116 to 7.4

    Hi I have a wlc 5508 running version 7.0.116.0 that I need to uppgrade to use the CAP2602I AP. I understand that I need to upgrade it to version 7.0.240 before 7.4.100 to avoid loosing HREAP VLAN mappings, and I have also read that i need to install

  • JDeveloper Tutorials

    Hi Folks I installed jdev9033 and started working on it using the tutorials (JDeveloper User Guide Part No A97276-01). To create a user interface, the tutorial on page 3-14 says to right-click on newly created projects node and choose 'New'. In the N

  • Does anyone have the library which contains the EPM Phasor?

    Hey, Several years ago I've made a program were the EPM Phasor VI was used in. Now after quite some time I want to modify a part of the program, which shouldn't be a big problem but I've lost the EPM Phasor vi from my computer and was too stupid to c