System Exit Overriding Busy Loop

Hi,
Why would the following code not result in a clean JVM termination when SIGINT is sent? The JVM appears to capture the SIGINT correctly (it hits the shutdown hook), but the System.exit(-1) call cannot seem to override the busy loop and terminate the spawned thread. Is this expected behavior for the VM?
public class TestSigInt {
     public TestSigInt()
          new Thread()
               public void run()
                    while(true)
          }.start();
          Runtime.getRuntime().addShutdownHook(new Thread()
               public void run()
                    System.exit(-1);
     public static void main(String[] args)
          TestSigInt tsi = new TestSigInt();
}Thanks,
hhung

Is this expected behavior for the VM?Yes. See javadoc for System.exit(), that leads to to Runtime.exit():
If this method is invoked after the virtual machine has begun its shutdown sequence then if shutdown hooks are being run this method will block indefinitely
So the method blocks (and presumably does nothing, but I admit I'm making up that last bit) if called as part of a shutdown hook.
the System.exit(-1) call cannot seem to override the busy loop and terminate the spawned threadRegardless of the fact that it's called from a shutdown hook, which previous messages (and the javadoc quoted) already question, there's nothing in the API javadoc that suggests that threads are gracefully "terminated".
This situation is not different from regular situations when you want to nicely end a thread in an otherwise running Java application: the API does not provide any built-in API (except Thread.stop() and destroy() which are deprecated and which use is strongly discouraged) to stop a running thread.
See Thread.interrupt() which somehow "kindly" requests interruption of a running thread, but this requires cooperation of the target thread (whose code shoud regularly poll Thread.getCurrentThread().isInterrupted() and terminate accrodingly).
The usual recommendation to make this more explicit in the code, is that the thread's code regularly checks a business-logic specific boolean, such as:
class StoppableTask implements Runnable {
    private boolean shouldContinue = true;
    public void run() {
        while (shouldContinue) {
            // do stuff
    public void requestStop() {
        shouldContinue = false;
public void class StopperThread {
    StoppableTask target;
    public void doOtherStuff() {
        target.requestStop();
}This requires cooperation form the target thread's code as well, so this is not conceptually different from the interrupt() scheme, it just has different scope (it won't unblock IOs for example).
Note that I deliberately used Runnable as opposed to Thread, first because it is a recommend practice (but you may know that already and your example was intentionally shorter to get to the point), second to highlight that the specific-solution does not use any built-in java.lang.Thread method.
Edited by: jduprez on Dec 8, 2009 11:28 AM

Similar Messages

  • Which system variable is reset at the exit of a loop of an internal table

    which system variable is reset at the exit of a loop of an internal table
    a)sy-loop b)sy-index c)sy-dbcnt d)sy-tabix

    You might want to revist your threads from Friday, and award points and mark as "Answered" or "Solved".
    Regards,
    Rich Heilman

  • How to terminate or exit a for loop when the user clicks on stop button

    Actually my problem is to stop a loop when i click on stop button.
    example:i have two buttons 'start' and 'stop'
    in start buttom i wrote a for loop as
    dim i as integer
    For i=1 To 100000
    print i
    Next
    when i click on start buuton it prints 'i' value up tp 100000.
    my question is when i click on 'Stop' button the for loop has to terminate or Exit from the  loop and should stops the execution.
    Is it possible to termianate or Exit the 'for loop'
    PS.Shakeer Hussain
    Hyderabad

    I am unable to stop the loop and application not at all allowing to Press the Stop button.
    It seems like Hung, any advise ?
    Private Sub btnStart_Click(sender As Object, e As EventArgs) Handles btnStart.Click
            btnStop.Enabled = True
            btnSelectFile.Enabled = False
            btnStart.Enabled = False
            btnStop.Focus()
            Dim strFileName As String = txtFileName.Text.ToString
            Dim strLineText As String
            If System.IO.File.Exists(strFileName) = True Then
                Dim objReader As New System.IO.StreamReader(strFileName)
                While objReader.Peek() <> -1 And stopclick = False
                    strLineText = objReader.ReadLine()
                    MsgBox(strLineText, MsgBoxStyle.Information)
                    Application.DoEvents()
                    Thread.Sleep(My.Settings("strDelay") * 1000)
                    'System.Diagnostics.Process.Start(My.Settings("strFireFoxLocation"), strLineText)
                End While
            End If
        End Sub
        Private Sub btnStop_Click(sender As Object, e As EventArgs) Handles btnStop.Click
            stopclick = True
            btnSelectFile.Enabled = True
            btnStart.Enabled = True
            btnStop.Enabled = False
        End Sub
    Raman Katwal
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Exiting a server loop

    hi guys,
    does anyone know the correct way to exit a server loop, at the moment i have ....
    while(!SrvInput.getEndProgStatus()){          
    sk = skt.accept();
    System.out.println("Accepting new client connection");
    serverThread st = new serverThread(sk, conn);
    st.start();
    this just loops around creating a new thread for every client that connects, i have a class SrvInput which reads input from the console so if the user types "quit" the end prog status flag is set to true and the server exits.
    the problem is that for it to exit i need one more person to connect since it blocks on the accept call.
    Does anyone know how i can sort this out
    thanks for any help

    Hi.
    I'm trying to solve the same problem. I solve it, sending myself a Socket conection and then existing the while code like this:
        public void run()
            while (!isFinish())
                try
                    System.out.println("Waiting for connections.");
                    Socket client = serverSocket.accept();
                    if (!isFinish())
                        System.out.println("Accepted a connection from: "+client.getInetAddress());
                        LocationThread connect = new LocationThread(client);
                }catch(Exception e)
                    System.out.println(e.getMessage());
                    e.printStackTrace();
            try
                System.out.println("Server exiting");
                join(); // remove  join(), this a test.....
                serverSocket.close();
                System.out.println("Server has exit");
            }catch(Exception e)
                System.out.println("Error al cerrar el Socket");
        }This code belongs to the server side.
    I do this, in a Button in a GUI interface.
            try{
                location.setFinish(true);
                Socket s = new Socket(InetAddress.getLocalHost(),Integer.parseInt(result));
            }catch(Exception e)
                System.out.println("Error al tratar de terminar el servidor");
            }But I have a problem, I want my server to wait for their childs to finish, How can I do it?.
    a Join() , do the server to hang.
    Any suggestion ?.

  • How  to track System.exit(0) call

    hi there,
    how can i trace the System.exit(0) function call in my program.
    i.e as we know which class is being loaded into the jvm by overriding
    the classloader, can we similarly know when is our jvm going to be
    destroyed. here iam invoking jvm from my windows program using invocation api.
    any help is mostly appreciated.
    thanks in advance
    bye
    ramana

    Not sure I know what you are asking.
    You could create a security manager which prevents exit() from being called.
    You could replace System using the bootstrap command line option. Although if you do that you can not distribute it due to the license agreement. Once replaced you can do anything you want in the application.
    You could use Runtime.addShutdownHook() if you just want to do something when the application exits.

  • System.exit(0); reboots PC..........

    Hello all,
    I compiled and ran this program with no problems about 5 or 6 times as soon as I finished writing it. I walked away for about 15 minutes and tryed to run it again. The program runs fine up until the end; now, however, at the System.exit(0); line the system promptly REBOOTS.
    I am running windows XP Pro.....
    Any ideas as to what may be causing this?
    1. Take input from user for how many numbers will be in the array.
    2. Allow user to input the values 0ne by one usig for loop and break loop upon reaching
    value input from number 1(above).
    3. Make class to do linear search
    import javax.swing.JOptionPane;
    public class LinearSearch
      public static void main(String args[]) {
    SearchArrayLinear X = new SearchArrayLinear();
        String input, input2, input3;
        int array[], len, element, key;
        input = JOptionPane.showInputDialog(null,
            "How many integers do you want to input into the array? ", "INPUT",
            JOptionPane.QUESTION_MESSAGE);
        len = Integer.parseInt(input);
        array = new int[len];
        for (int counter = 0; counter < len; counter++)
        array[ counter ] = Integer.parseInt( JOptionPane.showInputDialog(null,
                                      "Input index " + counter + " into the array",
                                      "INPUT", JOptionPane.QUESTION_MESSAGE) );
       X.linearSearch(array);
    class SearchArrayLinear
    public void linearSearch( int array2[] ) {
        String input = JOptionPane.showInputDialog(null, "Enter the Search key ",
                                             "Search Key Input",
                                             JOptionPane.QUESTION_MESSAGE);
        int key = Integer.parseInt(input);
    for( int counter = 0; counter < array2.length; counter++)
          if (array2[counter] == key) {
            JOptionPane.showMessageDialog(null,
                                          "The search key was found in element " +
                                          array2[counter], "RESULT",
                                          JOptionPane.INFORMATION_MESSAGE);
    System.exit(0);
          else {
            JOptionPane.showMessageDialog(null,
                " No element was found for the search key ",
                "RESULT",
                JOptionPane.INFORMATION_MESSAGE);
            System.exit(0);
    }

    Get this. Microsoft says that this is a "Driver problem" and to check the latest installed driver. At first, I didn't think much of it because I havn't installed any drivers or hardware between the time it was working and the time it quit working....or so I thought.
    Apparently, one of the Microsoft automatic updates was a new processor driver for XP Pro. Since then, I cannot run any java programs without using JBuilder8. If I do, the computer reboots whenever the program reads the System.exit(*); line.
    Looks like Microsoft has found yet another way to sabotage java.
    Go figure.

  • System.exit(0)   error in program.

    Any help appreciated. Let me first put my code here:
    Converts money using CurrencyConverter, there's another class I haven't posted here!! (which calculates conversion)
    import java.util.* ;
    public class CurrencyConverterTester
      public static void main(String[] args)
        Scanner in = new Scanner(System.in) ;
        System.out.println("How many euros is one dollar?") ;
        String input = in.nextLine() ;
        double rate = Double.parseDouble(input) ;
        CurrencyConverter myconverter = new CurrencyConverter(rate);
        System.out.println("Dollar value (Q to quit)") ;
        input = in.nextLine() ;
        while (true) {
          if (input == "Q"){
            System.exit(0);
            break;}
          else {
          System.out.println(input + " dollar = " +  myconverter.convert(Double.parseDouble(input)) + " euros");
          input = in.nextLine();
          continue;}   
    }The issue is that the program won't terminate when I enter Q as my input?? I'm guessing it might have something to do my conversion from string to double in the 'else' statement, but not sure. Also, if you can suggest a more simpler method for the last 'while' statement, that would be helpful as well. Thanks. (noob to java)

    paulcw wrote:
    Curse Gosling for making &#43; syntactic sugar for string append, but not overloading any other operators.@Paul
    What did you expect from a duck ;-)
    Seriously, yep, maybe it would have been better for noobs if the syntax of Java Strings was consistent with other kinds of Object... or maybe it would have been better if == was compiler-magiced into stringA.equals(stringB)... and the left and right shift operators have promise, and of course that way lies MADNESS, as witnessed in C&#43;&#43; ;-)
    @OP... You are (IMHO) using the break, continue and especially System.exit() inappropriately... see my comments in your code...
        System.out.println("Dollar value (Q to quit)") ;
        input = in.nextLine() ;
        // while-true-loops are a "fairly usual" way of doing this kind of stuff,
        // but that doesn't make them "the preferred option". Typically you would
        // explore more "vanilla approaches" (which don't rely on the break and
        // continue statements)... leaping straight to the "tricky approach" means
        // you haven't (most often out of sheer laziness) thought it through... and
        // ALL good computer programs are thoroughly thought through (yep, try
        // saying that three times fast, especially after three beers).
        while (true) {
          // You don't compare Strings using ==
          if ( "Q".equalsIgnoreCase(input) ) {
            // Either of the following statements will do the job. The call to exit
            // will exit the JVM, therfore the break statement cannot be reached,
            // so it is superflous, so it's presence is just a bit confusing. Having
            // said that, "real programmers" don't use System.exe routinely, only in
            // the case of an emergency, such as handling a fatal-error, such as an
            // out-of-memory condition... an even then it's usually indicative of a
            // poor "system design", because it terminates the JVM which is running
            // this program without giving anything else in the program a chance to
            // clean-up after itself... like ask the user if they want to save there
            // work, or whatever.
            // I would use break (if anything) instead of System.exit
            // ... and if I wrote the Java tutorials, exit wouldn't be mentioned at
            // all until both "normal" flow control, and exception handling had both
            // been thoroughly covered.
            System.exit(0);
            break;
          } else {
            // I would break this line up, probably into three lines, simply becuase
            // it's syntatically "a long line".
            // Also the name "myconverter" doesn't tell what the class is/does.
            // IMHO, currencyConverter would be a better (more meaningful) name.
            // HERE'S HOW I WOULD WRITE IT
            // double dollars = Double.parseDouble(input);
            // double euros = currencyConverter.convert(dollars);
            // System.out.println(input + " dollar = " + euros + " euros");
            System.out.println(input + " dollar = " +  myconverter.convert(Double.parseDouble(input)) + " euros");
            input = in.nextLine();
            // This continue statement is superflous. continue says "go back to the
            // top of loop, reevaluate the loop-condition (true in this case) and
            // (if the condition is still true) "Play it again Sam".
            // ... which is exactly what will happen without this continue statement
            // and hence (IMHO) your code is easier to follow without it, simply
            // because another programmer may waste there time trying to figure out
            // WHY that continue statement is present.
            continue;
        }*ALSO:* The format of that code totally sucks. Braces all over the place; improper indentation. No wonder you're struggling to read your own code. Please read and abide the [The Java Code Conventions|http://java.sun.com/docs/codeconv/] (at least until you have the requisite experience to formulate credible and compelling arguments as to why your "style" is superior to the standard, and that's no small ask). Yes this is *important*... trust me on this (for now)... especially if you are going to ask for help on the forums... You're effectively wasting our time asking us to decipher your code because you are too lasy to format it correctly... and I for one find that "self entitled" attitude ugly, and offensive... Help us help you... you know?
    And BTW.... Here's how I would actually do it.... no funky while-true, break, or continue... just a plain-ole'-while-woop....
    package forums;
    import java.util.Scanner;
    public class KRC
      private static final Scanner SCANNER = new Scanner(System.in);
      public static void main(String[] args) {
        try {
          String input = null;
          while ( !"Q".equalsIgnoreCase(input=enterDollarAmount()) ) {
            System.out.println(input + " dollars is " +  Double.parseDouble(input) + " euros.");
            System.out.println();
        } catch (Exception e) {
          e.printStackTrace();
      private static String enterDollarAmount() {
        System.out.print("Please enter an amount in dollars : ");
        return SCANNER.nextLine();
    }Edited by: corlettk on 25/10/2009 10:21 ~~ Distant Monarching Forum Markup!

  • Avoiding system.exit(0)

    Hi
    I am using an external .jar file in my java program for parsing a file. My problem is that its main method has System.exit statement in the end i.e after parsing it exits the application. So when i use it my application also gets terminated. I have decompiled it and the only accessible method is main method. Is there any way to avoid this system.exit(0) ?

    EJP wrote:
    You can run it under a SecurityManager and a .policy file which doesn't grant that permission.I am trying to overrite securityManager functions:
    like:
    private static void forbidSystemExitCall() {
        final SecurityManager securityManager = new SecurityManager() {
                @Override
          public void checkPermission( Permission permission ) {
                    System.out.println("persmiion");
            if( "exitVM".equals( permission.getName() ) ) {
             throw new SecurityException("System.exit attempted and blocked.");
                @Override
          public void checkExit(int exit)
              super.checkExit(exit);
              throw new SecurityException("System.exit attempted and blocked.");
        //System.setSecurityManager( securityManager ) ;
      }and calling above code as:
                 try
                        forbidSystemExitCall() ;
                        try
                           Main.main(strings);
                        catch( ExitTrappedException e )
                        finally
                          enableSystemExitCall() ;
                   catch ( Exception ex)
                       System.out.println("error calling main method");
                       ex.printStackTrace();
                   }but above code is not working as i requried.
    Or if you have stuff to do on exit you can add shutdown hooks, see java.lang.Runtime.i could not understand it, please kindly can you explain little bit more... I have not play with java security before.
    BR
    Umer

  • Stopping output tasks properly before exiting a For-loop

    Hi,
    I've been having some trouble exiting a For-loop conditionally. The problem is that when the loop is stopped conditionally (a button is pressed) the DAQ (NI USB 6353) outputs get stuck to whatever value they were in. I tried stopping the DAQ Assistant output task (1 sample on demand)  before exiting the loop but that didn't solve the problem. Should this perhaps be done one iteration before exiting the loop or can it be done in the same iteration round?
    What would be the "right" way to exit a for loop with output tasks so that the output signals would be 0V after exiting? I know that I could "force" feed the DAQ Assistant with 0V control before exiting but in this case that would be quite difficult...
    Any ideas? Help is appriciated.

    Yes, I get it... However at this point I don't think that's an option.
    Would this kind of solution work? ( I am not able to test all possible solutions in the real system which is why I would like to get a confirmation first)
    The idea is to connect the output of the "Or" port to the "Stop" -ports of the DAQ Assistants in the loop.
    Edit. Will the output automatically go to 0V if I just stop the task? I am not really sure about this.
    Thank you.
    Attachments:
    exit-loop.jpg ‏8 KB

  • Preventing System.exit()

    I've written a class loader that executes .jar files across a network from a central application. Works great - except when one of those jar files calls a System.exit().
    Since the purpose of this application is to have several applications "executing" across a network, having one of them call System.exit() kills all of them. Are there any methods of scanning the class files as they are being loaded and having code replaced? For example, searching for System.exit(someInt) or even JFrame.EXIT_ON_CLOSE and then replacing this bytecode with some more acceptable bytecode that instructs the parent program the child wishes to terminate?
    Rewriting all of the programs to be loaded so that they don't call System.exit() or its variations isn't an option here, so I'm open to any suggestions.

    BTW: Overriding system libraries is against
    standards, but does work.
    http://java.sun.com/j2se/1.4.2/docs/guide/standards/
    In java.lang.Runtime
    public void exit(int status) {
    throw new Error("Exit called with
    led with status="+status);
    }Create a jar and copy it to <java_home>/lib/endorsed
    The run the following
    public class Main {
    public static void main(String[] args) {
    System.exit(1);
    }And you will get the follow when run with this
    "modified" JRE
    "C:\Program Files\Java\jre1.6.0\bin"\java -cp .Main
    Exception in thread "main" java.lang.Error: Exit
    called with status=1
    at java.lang.Runtime.exit(Runtime.java:86)
    at java.lang.System.exit(Unknown Source)
    at Main.main(Main.java:11)
    Yes, but then it works only on your machine.

  • System.exit(0) - Avoid JVM termination

    Hi,
    Is there any possibility to avoid JVM termination when we use system.exit(0).
    I have created my own SecurityManager.
    public class MySecurityManager extends SecurityManager {.....}, and I can able to get S.O.P at public void checkPermission(final Permission permission) {..} and public void checkExit(int status) {..} in SecurityManager , My code in main() is
    MySecurityManager mySM = new MySecurityManager();
              System.setSecurityManager(mySM);
    System.out.println("Before......");
    System.exit(0);
    System.out.println("After......");
    i cant able to get SOP "After.....",
    Is there any possibility to raise exceptions when i introduce exit(0) in my java file.....? or Is there any possibility to avoid JAVA termination when i use System.exit(0).
    Thankx in Advance

    uh, System.exit is defined as the command to
    terminate the JVM. You can avoid that by not calling
    System.exit...Or do just what the OP tried to do.
    class Test {
         public static void main(String args[]) throws Exception {
              System.setSecurityManager(new ExitHandlingSecurityManager());
              System.out.println("Before");
              try {
                   System.exit(1);
              } catch (SecurityException e) {
                   System.err.println("Couldn't exit the VM: " + e.getMessage());
              System.out.println("After");
    class ExitHandlingSecurityManager extends SecurityManager {
         @Override
         public void checkExit(int arg0) {
              throw new SecurityException("You aren't allowed to terminate VM");
    }Prints:
    Before
    Couldn't exit the VM You aren't allowed to terminate VM
    After
    Kaj

  • System.exit(0) question

    What does the number 0 on System.exit(0);do? I have tried different digits but they all seem to do the same thing-terminate the virtual machine. So why the convention of 0 and not 7 or 13?

    stealing from the javadoc (Runtime.exit) (You might also want to look into overriding SecurityManager.checkExit method):
    Terminates the currently running Java virtual machine by initiating its shutdown sequence. This method never returns normally. The argument serves as a status code; by convention, a nonzero status code indicates abnormal termination.
    The virtual machine's shutdown sequence consists of two phases. In the first phase all registered shutdown hooks, if any, are started in some unspecified order and allowed to run concurrently until they finish. In the second phase all uninvoked finalizers are run if finalization-on-exit has been enabled. Once this is done the virtual machine halts.
    If this method is invoked after the virtual machine has begun its shutdown sequence then if shutdown hooks are being run this method will block indefinitely. If shutdown hooks have already been run and on-exit finalization has been enabled then this method halts the virtual machine with the given status code if the status is nonzero; otherwise, it blocks indefinitely.

  • Prevent System.exit(0)

    Hi Everybody!
    I have the following problem.
    I am developing an web-application running on a Tomcat server.
    Furthermore I am using some additional libraries, from which I only have the class-files. Nevertheless I decompiled them and found, that one method calls a System.exit(0) in its catch block, and this is horrible, because the server always shuts down in case of failure.
    What shall i do to prevent this? Altering the library will not be possible. Any ideas?
    I created a small example to point out my problem:
    public class Testing {
         private void methodA(String s) {
              try {
                   int i = Integer.parseInt(s);
                   System.out.println("Value of i: " +i);
                   Thread.sleep(1000);
              catch (Exception e) {
                   e.printStackTrace();
                   System.exit(0);
         }     //methodA
         public static void main(String[] args) {
              Testing t = new Testing();
              for (int i = 0; i < 10; i++) {
                   if (i == 5)
                        t.methodA("a");
                   else
                        t.methodA(String.valueOf(i));
              }     //for
    }Just think of methodA() as an method that can not be altered... How can I force the for-loop to continue when methodA() fails?
    (This is not my actual problem, but it points out my problem... ;)
    Thanks in Advance!
    Stef

    I was able to solve the problem by using the following code :-
    final SecurityManager securityManager = new SecurityManager()
         public void checkPermission(Permission permission)
              //This Prevents the shutting down of JVM.(in case of System.exit())
         if ("exitVM".equals(permission.getName()))
         throw new SecurityException("System.exit attempted and blocked.");
    System.setSecurityManager(securityManager);
    Hope it helps some one ..................... ;)

  • Catch/Prevent System.exit call in other thread

    Wasn't sure where to put this so apologies if this is in the wrong section.
    I have an application that runs a particular method contained in a JAR that is written/provided by somebody else (they implement an interface I provide). They have complete free range as to what their application does. I then run this application in a separate thread, the idea being that when it completes my original application is still running.
    What I have provided so far is ok PROVIDED that the given JAR does not perform a System.exit call which is very possible. I want to prevent them from doing this but I don't want to contacting the author asking them to remove all invokations of System.exit.
    I found this article: https://www.securecoding.cert.org/confluence/display/java/EXC04-J.+Prevent+against+inadvertent+calls+to+System.exit%28%29+or+forced+shutdown and so I tried to create my own SecurityManager. Unfortunately though despite explicitly putting the running of the applicaiton in a catch block for AccessControlException it doesn't catch it and fails. Does anybody have an idea of how to overcome this.
    In summary: how can I prevent a call to System.exit being invoked (or when it is invoked, catch it and prevent it from actually happening) inside another thread?

    batterj2 wrote:
    I was unable to do any File I/O afterwards which seems strange as its extending the original SecurityManager so I thought it wouldn't have any difference.No, that code isn't "extending the original SecurityManager". It's creating a SecurityManager which overrides some SecurityManager which may or may not be the same as the actual SecurityManager which was in place when you applied it. From what you say, it's not the same.
    Remember you don't extend objects, you extend classes.
    You could write something which gets a link to the current security manager, then delegates all calls to that security manager except the ones you don't want to delegate.

  • Simple split cache semantics on System.exit?

    We have observed, with the default configuration (no override xmls at all), that cache entries get lost under the following case:
    1) Start an instance with java -jar coherence.jar
    2) Run an application, also with no config overrides, that:
    -puts some entries in a named cache (timeout long)
    -System.exit()
    3) Then immediately run another app that tries to pull the entries from the same named cache
    Sometimes #3 works, and sometimes it finds nothing. In all cases, 2 & 3 do connect with 1.
    This leads to the following questions:
    1) Is the problem that the local cache is not being pushed into the backing partitioned cache before the exit?
    2) How can this be rectified (other than sleeping before exiting)?
    2A) Is there a "I'm done with this cache, but keep it in the backing store" semantics in one of the calls #2 could make?
    2B) Is there a parameter in getting the cache that can be used
    2C) Is there config that can insure that this always works
    2D) Is there a way that #2 can tell when its data has made it to the cluster (backing cache)?
    Thanks in advance

    Hi John,
    We have observed, with the default configuration (no
    override xmls at all), that cache entries get lost
    under the following case:
    1) Start an instance with java -jar coherence.jarAs I mentioned earlier, we used to have some problems with using the console application as a cache server. Please use DefaultCacheServer instead.
    2) Run an application, also with no config overrides,
    that:
    -puts some entries in a named cache (timeout long)
    -System.exit()Which cache? Different named caches have different semantics in the stock configuration. Did you use a transactional cache?
    Would you post your test code?
    3) Then immediately run another app that tries to
    pull the entries from the same named cache
    Sometimes #3 works, and sometimes it finds nothing.
    In all cases, 2 & 3 do connect with 1.
    This leads to the following questions:
    1) Is the problem that the local cache is not being
    pushed into the backing partitioned cache before the
    exit?There is no such concept as a local cache and a non-local in case of Coherence clustered caches.
    If the put method call returned, then that data is supposed to be cluster durable.
    The only situations I can come up with off my head for what you wrote to be normal (considering that there is cluster node 1 which supposed to live through all which you wrote) is if you
    - either put your data to a cache configured to be a LocalCache (it is not clustered)
    - or if you put it into a partitioned cache with backup-count configured to be zero (which is not the default setting).
    - or if you put it into a TransactionMap and you did not commit it.
    - programming errors somewhere
    2) How can this be rectified (other than sleeping
    before exiting)?I think that should work fine as it is.
    2A) Is there a "I'm done with this cache, but keep it
    in the backing store" semantics in one of the calls
    #2 could make?There is the CacheFactory.shutdown() call indicating polite departure. However its omission should not explain this situation.
    2B) Is there a parameter in getting the cache that
    can be usedUsed for what? I don't understand the question...
    2C) Is there config that can insure that this always
    worksI think, it should work out of the box.
    2D) Is there a way that #2 can tell when its data
    has made it to the cluster (backing cache)?
    In general, the return of the put operation means that the data is cluster-durable (if backup count is at least one for partitioned caches and there is another node or there is another node running the service in case of replicated caches).
    Best regards,
    Robert

Maybe you are looking for