Java Two Threads Synchronization Problem

Hello to all, i have a scenario like this where a manager open a restaurant which signal the arrival of customer.
Each entity here is one thread.
How to signal the customer from manager that is open state ?
I have a boolean variable (IsOpen) in manager class.
My code:
public class Manager implements Runnable {
     boolean IsOpen, IsStartWorking, IsLastOrder,
          IsClosingTime;
     public void run()
         try
              // while not closing time
              while (true)
                   if (!IsOpen && !IsStartWorking)
                        open();
                        startWorking();
                   prepareCappuccino();
                   prepareHotChocolate();
                   prepareFruitJuice();
                   // serve drink then refill Ingredients based on
                   // order
                   myCoffeePowder.refillCoffeePowder();
                   myCocoPowder.refillCocoPowder();
                   myMilk.refillMilk();
                   myFJ.refillFruitJuice();
                   Thread.sleep(100);
              // Manager alert closing time
              //closingtime();
               //sanityCheck();
               //statisticsDispaly();
               //managerLeave();           
         catch(InterruptedException e)
              e.printStackTrace();
          public void open() {
         IsOpen = true;
          System.out.println(dateFormat.format(cal.getTime()) +
               " Thread Manager: Manager open Restaurant");
          //notifyAll();
}I want to notify the customer thread when the IsOpen state become true.
As you can see from open() method, there is notifyAll() but it turn error because it does not own the monitor.
I have solution like this create a monitor with Isopen variable and once is open notifyAll().
I never tried that.
Please give some comment.
The logic here is model using FSP like below
MANAGER = (manager.open->startWorking->STARTWORKING),
CUSTOMER = (manager.open->CUST_ARRIVE),manager.open is a shared action in FSP.
Please help.
Thanks.

I think you had taken notify and notifyall in not correct way. According to me you need a another class say HotelManagement which hold the information of state of Manager and customer. This will hold the list of customer which are requsting to be allowed in hotel.So this class has methods like (Please pardon me for choosing some bad names ..I hope you will find some better names).
1. updateStateOfManager() = which allow manager to Update its state. and if state become open it will take each customer from RequsetedCustomer list and call their allowed method. If state become Closed it will take each customer from RequsetedCustomer list and call their removed method.
2. requestfromCustomer()= this method called by customer requesting for entry in hotel. if the state is open it allowed them immediately and kept in RequestedCustomer list too so that they can be removed when manager state changed. and if manager state is closed they are not allowed but kept in RequsetedCustomer list.
3. finshedFromCustomer()= customer done in hotel so remove from RequsetedCustomer list;
You can used AtomicBoolean objects for keeping state of Manager other thread safe data Structure for holding other objects.

Similar Messages

  • Question on java.lang.Thread "starting problems"

    hi everybody
    i've just little trouble running a tiny program which uses Threads.
    maybe there's a misunderstanding from my side:
    About my code:
    01  public class MyThread extends Thread {
    02
    03    String any_string = null;
    04
    05    public MyThread(String param) {
    06      any_string = param;
    07      this.start();
    08    }
    09
    10    public void run() {
    11      while(!isInterrupted()) {
    12        System.out.println(" > This Thread is running!");
    13        // any other operation...
    14        try {
    15        sleep(1000);
    16      }
    17      catch(Exception e) {}
    18    }
    19  }This is a Thread's code similar to those you can find it in the java.lang.Thread Documentation or in the java Tutorial.
    In my example I got a IllegalThreadStateException in codeline 07 which means (compare to java.lang.Thread Documentation) that the code tries to start the Thread while the Thread is still running.
    I always thought a Thread will not start itself.
    I thought (and that's the way, i red it in the documentation) that the constructor of a Thread only allocates the new Thead-Object.
    But by constructing MyThread I got the descripted exception (i'm beginning to repeat myself...). The "funny" thing on this exception is that the Thread at least IS running but there could be no Object allocated
    01  ...
    02  /**
    03   * construction of a new Object of the class MyThread.
    04   * test will be auto-started by the MyThread constructor
    05   */
    06  MyThread test = new MyThread("any-string");
    07  ...
    08  test.anyMethodOfClassMyThread();This little code generates a java.lang.NullPointerException in line 08 (when trying to access the object of class MyThread). Even after the application exits (in case of this exception), the run()-Method of MyThread generates its Text-Output " > This Thread is running!". argh
    Does anyone see my mistake / misunderstanding??
    It's really frustrating if you are sitting in front of your pc and can't get the reason why your prog is generating that "bullshit" (ok... i know - it's only generatting the bullshit I told it to generate :( )
    Any suggestions or ideas
    thanks,
    Thof

    Well now, I don't get a NullPointerException, when I try to call a method of MyThread. Here's your code, with slight modifications by me:
    public class MyThread extends Thread {
        String any_string = null;
        public MyThread(String param) {
            any_string = param;
            this.start();
        public String getAnyString(){
            return any_string;
        public void run() {
            while(!isInterrupted()) {
                System.out.println(" > This Thread is running!");
                try {
                    sleep(1000);
                catch(Exception e) {}
    }To test the app I wrote this class:
    public class TestMyThread {
        public static void main(String[] args) {
            MyThread temp = new MyThread("Hello World");
            System.out.println(temp.getAnyString());
    }Now it does print out the correct "Hello World".
    Your other problem of the thread not shutting down is because it is not a daemon thread. To solve this you will need to add this Thread to a ThreadGroup and set the ThreadGroup as a Daemon group. (see ThreadGroup::setDaemon() )
    Or you can put a little boolean in your while loop and break out when you change the value of the boolean. Then when you want to shut down you simply change the boolean
    Hope this helps
    -Philip

  • Thread Synchronization problem

    We guys are developing a P2P file sharing software(on LAN) and our program requires that we implement a multi-threaded client. I somewhere read on the forum about a multi threaded server but it doesnt work in my case (not on the client side.)The program runs properly when a single transfer is happening but if more then one file is getting downloaded the program seems to fall apart. Here's the code that provides the client side implementation of a file transfer.
    class Down implements Runnable     
                         DataOutputStream dataOutput;     
                         BufferedInputStream bufferedInput;     
                         FileOutputStream fileOutput;
                         Socket down;
                         public void run()
                                      try
                                              int data=0;
                                              long i=0;
                                              down=new Socket(user,9999);
                                              dataOutput=new DataOutputStream(down.getOutputStream());  //The following two lines send the file path to the server, to make the server's job easier rather than the server going for a file search
                                              String msg=path.replace('\\','/');   dataOutput.writeUTF(msg);     
                                              dataOutput.flush();
                                              bufferedInput=new BufferedInputStream(down.getInputStream());
                                              fileOutput=new FileOutputStream(new File(path));
                                              while (data != -1)
                                                       data=bufferedInput.read();
                                                       fileOutput.write(data);
                                                       fileOutput.flush();
                                                       i++;
                                                       System.out.println("Transferring "+i);
                                              System.out.println("File Transfer Done");
                                              done=true;
                                     catch (Exception e)
                                                 e.printStackTrace();
                                     } Can you guys point out specifically where my program would need synchronization, since im a noob when it comes to threads. Thanks

    Thanks ejp for those prompt replies .......yeah the path and the down socket) variables are unique...... from what i see on my network .... the server side of the transfer happens at a faster rate i.e the final println line printing the transferred byte (at the end of the while loop) is much ahead at the server side of the transfer ...... the client lags far behind in this regard...... and from what i know Lan connections support upto 100Mbps so there's no question of data loss..... one of the reasons i opted for byte by byte transfer....... just to be on the safer side...... and yes ill make that small change in my program

  • 64-bit JNI C++ to JAVA invocation multiple threads classloader problem

    Hi ALL,
    I have a C++ app that invokes Java classes on 64-bit Solaris 10 with 64-bit JVM.
    Here is the problem:
    The native non-main (not the thread that initializes the JVM) threads would not be able to find any user-define class.
    Here are the symptoms and observations:
    1. JNIEnv::ExceptionDescribe() showed the following StackOverflowError:
    Exception in thread "Thread-0" java.lang.StackOverflowError
            at java.util.Arrays.copyOf(Arrays.java:2734)
            at java.util.Vector.ensureCapacityHelper(Vector.java:226)
            at java.util.Vector.addElement(Vector.java:573)
            at java.lang.ClassLoader.addClass(ClassLoader.java:173)
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
            at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)2. The "main thread" that instantiates the JVM has no problem finding and loading any class or method
    3. But the other threads (non-main threads) would not be able to find the user-defined classes unless the classes were already loaded by the main thread.
    4. The non-main threads can find the "standard" java classes with no problem
    5. The same app ran fine on 32-bit system.
    6. Except for the JVM reference is global, each thread acquired JNIEnv by either GetEnv() or AttachCurrentThread().
    Any idea why it is a problem with 64-bit?
    I have the sample program to reproduce this issue in this thread: http://forums.sun.com/thread.jspa?messageID=10885363&#10885363. That was the original thread I raised but I have narrowed it down to a more concrete scenario. That's why I am creating this new thread. I hope this does not break any rule on this forum. If it does, I apologize.
    I really appreciate it if anyone can provide any help/suggestion.
    Regards,
    - Triet

    Here is the sample program. Again, this works on 32-bit but not 64-bit.
    #include <string>
    #include "jni.h"
    #include "TestThread.h"
    static JavaVM *g_pjvm = NULL;  /* denotes a Java VM */
    static JNIEnv *g_penv = NULL;  /* pointer to native method interface */
    void initJVM(char** jvmOptions) {
        printf("RJniTest init starts...\n");
        JavaVMInitArgs vm_args; /* JDK/JRE 6 VM initialization arguments */
        JavaVMOption* poptions;
        int optionLen = 0;
        while (jvmOptions[optionLen]) {
            optionLen++;
        printf("RJniTest::init len=%d\n", optionLen);
        if (optionLen > 0) {
            printf("RJniWrapper::init jvmOptions\n");
            poptions = new JavaVMOption[optionLen];
            //poptions[0].optionString = "-Djava.class.path=/usr/lib/java";
            int idx = 0;
            while (jvmOptions[idx]) {
                poptions[idx].optionString = jvmOptions[idx];
                idx++;
        printf("RJniTest::init vm_args: version(%x), nOptions(%d)\n",
                JNI_VERSION_1_6, optionLen);
        vm_args.version = JNI_VERSION_1_6;
        vm_args.nOptions = optionLen;
        vm_args.options = poptions;
        vm_args.ignoreUnrecognized = JNI_FALSE;
        // load and initialize a Java VM, return a JNI interface
        // pointer in env
        printf("RJniTest::init creates JVM\n");
        JNI_CreateJavaVM(&g_pjvm, (void**)&g_penv, &vm_args);
        printf("RJniTest init ends\n");
    void findClass(const char* classname) {
        static const char* fname = "justFindClasses";
        printf("%s: findClass: %s\n", fname, classname);
        JNIEnv* jenv;
        jint ret = g_pjvm->GetEnv((void**)&jenv, JNI_VERSION_1_6);
        if (ret == JNI_EDETACHED) {
            ret = g_pjvm->AttachCurrentThread((void**)&jenv, NULL);
            if (ret != JNI_OK || jenv == NULL) {
                printf("%s: get env error: ret=%d\n", ret, fname);
            } else {
                printf("%s: got new env\n", fname);
        } else if (ret == JNI_OK) {
            printf("%s: env already there\n");
        jclass classref;
        classref = jenv->FindClass(classname);
        if (classref == NULL) {
            printf("%s: %s class not found!\n", fname, classname);
            if (jenv->ExceptionOccurred()) {
                jenv->ExceptionDescribe();
                jenv->ExceptionClear();
        printf("%s: found class: %s\n", fname, classname);
    class RJniTestThread : public TestThread {
    public:
        void threadmain();
    void RJniTestThread::threadmain() {
        printf("RJniTestThread::threadmain: Starting testing\n");
        findClass("org/apache/commons/logging/Log");
        findClass("java/util/List");
        printf("RJniTestThread::threadmain: done.\n");
    int main(int argc, char** argv) {
        char **jvmOptions = NULL;
        printf("RJniTestDriver starts...\n");
        if (argc > 1) {
            jvmOptions = new char*[argc];
            for (int i = 0; i < argc ; i ++) {
                jvmOptions[i] = argv[i + 1];
            jvmOptions[argc - 1] = NULL;
        } else {
            int size = 8;
            int i = 0;
            jvmOptions = new char*[size];
            jvmOptions[i++] = (char*) "-Djava.class.path=<list of jar files and path here>";
            jvmOptions[i++] = (char*) "-Djava.library.path=/sandbox/mxdev/3rdparty/java/unix/jdk1.6.0_14/jre/lib/sparc";
            jvmOptions[i++] = (char*) "-Djava.compiler=NONE";
            jvmOptions[i++] = (char*) "-verbose:jni";
            jvmOptions[i++] = (char*) "-Xcheck:jni";
            jvmOptions[i++] = NULL;
        printf("init JVM\n");
        initJVM(jvmOptions);
        // UNCOMMENT HERE
        // findClass("org/apache/commons/logging/Log");
        // findClass("java/util/List");
        // UNCOMMENT END
        printf("start test thread\n");
        RJniTestThread testThread;
        ThreadId tid = testThread.launch();
        printf("wait for test thread\n");
        int ret = pthread_join(tid, NULL);
        printf("RJniTestDriver ends\n");
    }

  • Two Threads Sharing the Same Object

    I am learning Java multithreading recently and I really hit the wall when I came to synchronizing data using the synchronized keyword. According to the explanation, synchronized will only work when 2 or more threads are accessing the same object. If there are accessing 2 different objects, they can run the synchronized method in parallel.
    My question now is how to make sure for synchronized method to work, I am actually working with the same and only one object??
    Imagine this:
    Two person with the same account number are trying to access the very ONE account at the same time.
    I suppose the logic will be:
    Two different socket objects will be created. When it comes to the login or authentication class or method, how can I make sure in term of object that the login/authentication class or method will return them only ONE object (because they share the same account), so that they will be qualified for using the synchronized method further down the road?
    Thanks in advance!

    Actually your understanding is wrong. Consider:
    public class MyClass {
      private int someInt;
      private float someFloat;
      private synchronized void someMethod(final int value) {
        if (value > 2000) someInt = 2000;
      private synchronized void someOtherMethod(final float value) {
        if (value > 2.0) someFloat = 1.999f;
    }YOu might think that two different threads can enter this code, one can enter in someOtherMethod() while one is in someMethod(). That is wrong. The fact is that synchronization works by obtaining synchronization locks on a target object. In this case by putting it on the method declaration you are asking for the lock on the 'this' object. This means that only one of these methods may enter at a time. This code would be better written like so ...
    public class MyClass {
      private int someInt;
      private float someFloat;
      private void someMethod(final int value) {�
        synchronized(someInt) {
          if (value > 2000) someInt = 2000;
      private void someOtherMethod(final float value) {
        synchronized(someFloat) {
          if (value > 2.0) someFloat = 1.999f;
    }In this manner you are only locking on the pertinent objects to the method and not on 'this'. This means that both methods can be entered simultaneously by two different threads. However watch out for one little problem.
    public class MyClass {
      private int someInt;
      private float someFloat;
      private void someMethod(final int value) {�
        synchronized(someInt) {
          if (value > 2000) {
            someInt = 2000;
            synchronized (someFloat) {
              someFloat = 0.0f;
      private void someOtherMethod(final float value) {
        synchronized(someFloat) {
          if (value > 2.0) {
            someFloat = 1.99999f;
            synchronized (someInt) {
              someInt = 0;
    }In this case you can have a deadlock. If two threads enter one of these methods at the same time one would be waiting on the lock for someInt and the other on the lock for someFloat. Neither would proceed. The solution to the problem is simple. Acquire all locks in alphabetical order before you use the first.
    public class MyClass {
      private int someInt;
      private float someFloat;
      private void someMethod(final int value) {�
        synchronized (someFloat) {
          synchronized(someInt) {
            if (value > 2000) {
              someInt = 2000;
              someFloat = 0.0f;
      private void someOtherMethod(final float value) {
        synchronized(someFloat) {
          if (value > 2.0) {
            someFloat = 1.99999f;
            synchronized (someInt) {
              someInt = 0;
    }In this manner one thread will block waiting on someFloat and there can be no deadlock.

  • Need help for thread synchronization

    Hi guys,
    i got some problem with the thread synchronization.
    actually my code is like,
    class myClass
    public static void main()
    PvsIdentify identifyThread = new PvsIdentify(this); //Child trd 1
    PvsPolling pollingThread = new PvsPolling(this); //Child trd 2
    identifyThread.start();
    pollingThread.start();
    synchronized(this) {
    try {
    this.wait();
    } catch (Exception ex) {
    ex.printStackTrace();
    /// Code to follow based on the ouput from these two child threads
    if( ! identifyThread.getOutput() =="")
    my requirement is ,
    the identifyThread is giving an output. so after the completion of that child thread only IF condition should execute.
    but for me the IF condition is getting execute before the complete execution of identifyThread.
    what may be the problem.
    thanx in advance.---------------Subbu

    my problem is, that child thread identifyThread will do some process and final throw the output in a JOption dialog box to the main window.
    if we use join for the child thread then that dialog box will not come the the main window.
    This is my code,
              businessCancel = false;
              pollingCancel = false;
              String userName = txtInputId.getText();
                    //CHECK FOR EXISTANCE OF USER NAME
                    boolean isNameExist=false;
                    int isString = this.isValidName(userName);
                    try { // This code block invokes the PalmsSEIPort:isNameExist operation on web service
                        palmsecuresdk.sample.Palms palms = new palmsecuresdk.sample.Palms_Impl();
                        palmsecuresdk.sample.PalmsSEI _palmsSEIPort = palms.getPalmsSEIPort();
                        isNameExist = _palmsSEIPort.isNameExist(userName);
                        System.out.println("The result of isNameExist is==="+isNameExist);
                    } catch(javax.xml.rpc.ServiceException ex) {
                        // TODO handle ServiceException
                    } catch(java.rmi.RemoteException ex) {
                        // TODO handle remote exception
                    } catch(Exception ex) {
                        // TODO handle custom exceptions here
                    if(isNameExist==false)
                        if (isString==1) {
                            // CHECK FOR EXISTANCE OF USER PALM DATA
                            //Identify process
                            setComponentEnabled(false);
                            PvsIdentify identifyThread = new PvsIdentify(this);
                            PvsPolling pollingThread = new PvsPolling(this);
                            identifyThread.start();  
                            pollingThread.start();
                            btnCancel.requestFocus();
                            synchronized(this) {
                                    try {
                                        System.out.println("the owner of this thread is "+this.getOwner());
                                         identifyThread.join();
                                         pollingThread.join();
                                        System.out.println("Main thread is sleeping now");
                                    } catch (Exception ex) {
                                        ex.printStackTrace();
                            this.notifyAll();
                            System.out.println("After the identify process over");
                            String isPalmExist = identifyThread.getFinalResult();
                            while(isPalmExist.equals(""))
                                isPalmExist = identifyThread.getFinalResult();
                                if(!isPalmExist.equals(""))
                                    this.notifyAll();
                            System.out.println("The identify result is "+isPalmExist);
                            if(isPalmExist.equalsIgnoreCase("Identify Failed"))
                                // To display PROCEED MsgBox
                                identifyThread.result=102;
                                identifyThread.resultNotify(isPalmExist);                           
                                // Execute enrollment process.
                                setComponentEnabled(false);
                                PvsEnroll enrollThread = new PvsEnroll(this, this, userName);
                                //PvsPolling pollingThread = new PvsPolling(this);
                                enrollThread.start();
                                pollingThread.start();
                                btnCancel.requestFocus();                           
                            else
                                identifyThread.result=101;
                                identifyThread.resultNotify(isPalmExist);
                        else {
                                // Guidance display(ID is not correct.)
                                String message = langFileAccessor.getLangInfo(
                                                                        PvsLangFileAccessor.KEY_GUIDANCE_ILLEGALID);
                                dispGuidance(message);
                                initState();
                    else
                        String message = langFileAccessor.getLangInfo(PvsLangFileAccessor.KEY_GUIDANCE_EXISTINGID);
                        dispGuidance(message);
                        initState();
                    }

  • Java Bean Thread Safety

    I've been using JavaBeans for years now, and have read at least 30 different texts and online resources about using Java beans in JSPs. But in every single one of them, they are ambiguous and non-committal about how to properly use them to avoid Thread-Safety problems in a multithreaded (web server) environment. Are there any true Java gurus out there who know how to do so in JSPs?
    Specifically, when you use the <jsp:useBean> tag, that tag automatically binds an instance of your bean to the PageContext object. Since the PageContext object is shared by many threads, wouldn't this automatically make all of the Java Bean's properties vulnerable for thread problems? Since the pageContext is shared between threads, wouldnt one have to declare every one of the bean's setters and getters as "synchronized", to prevent one thread overwriting another's values?
    I ask because in many texts, they make a vague suggestion "be sure to write your beans thread-safe"--but provide no concrete answer as to how (the level at which to declare 'synchronized'). But in all their code examples, I have never once, in all these years, seen the word "synchronized".
    How is this possible? Wouldn't the bean, as bound to the thread-shared pageContext object, be completely exposed to thread corruption, with multiple threads simultaneously calling its methods?
    Can someone supply some code snippets showing the thread-safe way to use JavaBeans (i.e., where to synchronize)

    PageContext is shared by many threads?
    Not at one time, I'm pretty certain of that.
    From the API: A PageContext instance is obtained by a JSP implementation class by calling the JspFactory.getPageContext() method, and is released by calling JspFactory.releasePageContext().
    The to me suggests the contract that a PageContext can only be in use by on one JSP page at a time. As far as I am concerned, pageContext can be treated like a "local variable" to a jsp page.
    The contents of the pageContext object are maybe a different story, but we'll get to that.
    The things to worry about with thread safety are the same as they are for servlets.
    1 - Class attributes are not threadsafe. ie variables declared within <%! %> signs
    2 - Session attributes are potentially not threadsafe if the user makes two quick requests in a row (handling two requests for the same session)
    3 - Application attributes are never threadsafe as any currently running request can access them. Most Application level attributes I treat as read only (kinda like Singleton access)
    I don't see the need to go overboard declaring everything "synchronized". In fact I think it would be hugely detrimental.

  • Concurenncy - synchronization problems

    Hello,
    I have read about synchronization in about 5 sources so far and I still don't understand it and mostly because of codes that sources show do not work as they are intended to work.
    For example I will show the code from this webpage: http://www.roseindia.net/java/thread/SynchronizedThreads.shtml
    I tried this code:
    class Share extends Thread{
      static String msg[]={"This", "is", "a", "synchronized", "variable"};
      Share(String threadname){
        super(threadname);
      public void run(){
        display(getName());
      public synchronized void display(String threadN){
        for(int i=0;i<=4;i++)
          System.out.println(threadN+msg);
    try{
    this.sleep(1000);
    }catch(Exception e){}
    public class SynThread1 {
    public static void main(String[] args) {
    Share t1=new Share("Thread One: ");
    t1.start();
    Share t2=new Share("Thread Two: ");
    t2.start();
    }And my output the most time is the same like they showed so it's like:Thread One: This
    Thread One: is
    Thread One: a
    Thread One: synchronized
    Thread One: variable
    Thread Two: This
    Thread Two: is
    Thread two: a
    Thread Two: synchronized
    Thread Two: variableHowever, sometimes when i run this program it's like:Thread Two: This
    Thread One: This
    Thread One: is
    Thread One: a
    Thread One: synchronized
    Thread One: variable
    Thread Two: is
    Thread Two: a
    Thread Two: synchronized
    Thread Two: variable
    Okay I decided to make my own program the counter, who will start two threads at the same time which will use the same variable from the same object.
    Here it is:public class Main
    public static void main(String[] args) throws InterruptedException
    Counter counter = new Counter();
    Thread t = null;
    t = new Thread(new CounterRunnable(counter, true), "theOneWhoIsIncreased");
    t.start();
    t = new Thread(new CounterRunnable(counter, false), "theOneWhoIsDecreased");
    t.start();
    class Counter
    public synchronized void increaseCounter()
    counter++;
    System.out.println("I'm being increased");
    public synchronized void decreaseCounter()
    counter--;
    System.out.println("I'm being decreased");
    public synchronized int getCounter()
    System.out.println("Here "+Thread.currentThread()+" The result is: "+ counter);
    return counter;
    private int counter = 500;
    class CounterRunnable implements Runnable
    public CounterRunnable(Counter counter, boolean increase)
    this.increase = increase;
    this.counter = counter;
    public void run()
    for (int i = 0; i < 10; i++)
    if(increase)
    counter.increaseCounter();
    else
    counter.decreaseCounter();
    counter.getCounter();
    boolean increase;
    Counter counter;
    But unluckly results are like that, even though methods are synchronized, why?? run:
    I'm being increased
    I'm being decreased
    Here Thread[theOneWhoIsDecreased,5,main] The result is: 500
    I'm being decreased
    Here Thread[theOneWhoIsDecreased,5,main] The result is: 499
    I'm being decreased
    Here Thread[theOneWhoIsDecreased,5,main] The result is: 498
    I'm being decreased
    Here Thread[theOneWhoIsDecreased,5,main] The result is: 497
    I'm being decreased
    Here Thread[theOneWhoIsDecreased,5,main] The result is: 496
    I'm being decreased
    Here Thread[theOneWhoIsDecreased,5,main] The result is: 495
    I'm being decreased
    Here Thread[theOneWhoIsDecreased,5,main] The result is: 494
    I'm being decreased
    Here Thread[theOneWhoIsDecreased,5,main] The result is: 493
    Here Thread[theOneWhoIsIncreased,5,main] The result is: 493
    I'm being increased
    Here Thread[theOneWhoIsIncreased,5,main] The result is: 494
    I'm being increased
    Here Thread[theOneWhoIsIncreased,5,main] The result is: 495
    I'm being increased
    Here Thread[theOneWhoIsIncreased,5,main] The result is: 496
    I'm being increased
    Here Thread[theOneWhoIsIncreased,5,main] The result is: 497
    I'm being increased
    Here Thread[theOneWhoIsIncreased,5,main] The result is: 498
    I'm being increased
    Here Thread[theOneWhoIsIncreased,5,main] The result is: 499
    I'm being increased
    Here Thread[theOneWhoIsIncreased,5,main] The result is: 500
    I'm being increased
    Here Thread[theOneWhoIsIncreased,5,main] The result is: 501
    I'm being increased
    Here Thread[theOneWhoIsIncreased,5,main] The result is: 502
    I'm being decreased
    Here Thread[theOneWhoIsDecreased,5,main] The result is: 501
    I'm being decreased
    Here Thread[theOneWhoIsDecreased,5,main] The result is: 500
    I supossed that results would be like first only increasing and then only decreasing output, or first deacreasing and then increasing output. Why is that different?
    I know that I can achieve that thing by for example using *join* method but well I want to understand synchronization ;)
    So what's the problem, I'm totally confused about that synchronization things. Somehow i still think it doesn't work at all. I learnt about the object which is called Lock also, about the ReentrantLock... and well it still doesn't work good with that...
    Please explain me what is the problem, i'm really confused...
    Best regards,
    Armon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    The first example doesn't work because the display method synchronizes on different objects (their own instance). A quick fix could be to synchronized on the Share.class, but since anyone could lock on that (if it was public), better make a local lock object.
    // quick fix
    public void display(String threadN){
      synchronized(Share.class) {
        for(int i=0;i<=4;i++)
          System.out.println(threadN+msg);
    try{ this.sleep(1000); } catch(Exception e) {}
    // better, though should really extend Thread
    class Share extends Thread {
    private final Object lock;
    Share(String threadname, Object lock){
    super(threadname);
    this.lock = lock;
    public void display(String threadN){
    synchronized(lock) {
    public class SynThread1 {
    public static void main(String[] args) {
    Object lock = new Object();
    Share t1=new Share("Thread One: ", lock);
    t1.start();
    Share t2=new Share("Thread Two: ", lock);
    t2.start();
    You own example has the same problem: synchronizing on different objects.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • The JAVA program for "Philosopher Problem"

    When I learn the book of "Operating Systems (Design and Implementation)"(written by Andrew S.Tanenbaum), I try to write a program for the "Philosopher Problem" . In the book there is a sample of this problem in C language, and I write it in JAVA. The following is my program, I have tested it. It is correct, but maybe it is not the most efficient way to solve the problem. Can you think out a more efficient program in JAVA to solve this problem?
    * Philosopher Eating Problem
    * @author mubin
    * @version 1.0
    public class PhilosopherEating {
    //Philosophers' number
    private final static int PHER_NUM = 20;
    //Philosophers' state
    private volatile static int[] pherState = new int[PHER_NUM];
    //THINKING
    private final static int THINKING = 0;
    //HUNGRY
    private final static int HUNGRY = 1;
    //EATING
    private final static int EATING = 2;
    //Philosophers thread group
    public static Philosopher[] philosophers = new Philosopher[PHER_NUM];
    //finish indicator
    public volatile static boolean finished =false;
    //thread lock
    public static Object threadLock = new Object();
    public PhilosopherEating() {
    * Philosopher class
    * @author mubin
    * @version 1.0
    public static class Philosopher extends Thread{
    int pherNo ;
    public Philosopher(int no){
    this.pherNo = no;
    public void run(){
    while(!PhilosopherEating.finished){
    think();
    takeForks(this.pherNo);
    eat();
    putForks(this.pherNo);
    * Thinking
    private void think(){
    System.out.println("Philosopher"+this.pherNo+"is thinking...");
    try {
    Thread.sleep( (int)(Math.random()*100));
    }catch (Exception ex) {
    ex.printStackTrace(System.out);
    * Eating
    private void eat(){
    System.out.println("Philosopher"+this.pherNo+"is eating...");
    try {
    Thread.sleep( (int)(Math.random()*100));
    }catch (Exception ex) {
    ex.printStackTrace(System.out);
    * Take the fork
    private void takeForks(int no){
    //System.out.println("takeForks:no:"+no);
    synchronized (threadLock) {
    pherState[no] = HUNGRY;
    testPher(no);
    * Put down the fork
    private void putForks(int no){
    //System.out.println("putForks:no:"+no);
    synchronized (threadLock) {
    pherState[no] = THINKING;
    if( pherState[getLeft()]==HUNGRY ){
    philosophers[getLeft()].interrupt();
    if( pherState[getRight()]==HUNGRY ){
    philosophers[getRight()].interrupt();
    * Return the NO. of philosopher who is sitting at the left side of this philosopher
    * @return the NO. of the left philosopher
    private int getLeft(){
    int ret = (pherNo-1)<0? PHER_NUM-1 : (pherNo-1);
    return ret;
    * Return the NO. of philosopher who is sitting at the right side of this philosopher
    * @return the NO. of the right philosopher
    private int getRight(){
    int ret = (pherNo+1)>=PHER_NUM ? 0 :(pherNo+1);
    return ret;
    private void testPher(int no){
    while(true){
    if(pherState[no]==HUNGRY
    &&pherState[getLeft()]!=EATING
    &&pherState[getRight()]!=EATING) {
    pherState[no] = EATING;
    //Print and check the philosophers' state
    printPher(pherState);
    return;
    }else{
    try {
    System.out.println(" Philosopher "+this.pherNo+"is waiting a fork");
    threadLock.wait();
    }catch (java.lang.InterruptedException ex) {
    System.out.println(" Philosopher "+this.pherNo+"is interrupted and woken up to take fork");
    //when it is interrupted, do nothing. Just let it continue!
    }//end of while(true)
    * Print and check the philosophers' state.
    * To insure there are no two philosophers sit side by side
    * are eating at the same time.
    private static void printPher(int[] phers){
    System.out.print(" philosophers' state��");
    for (int i = 0; i < phers.length; i++) {
    System.out.print(" "+phers);
    System.out.println("");
    for (int i = 0; i < phers.length-1; i++) {
    if (phers[i]==EATING && phers[i+1]==EATING){
    System.err.println(i+" and "+(i+1)+"two of philosophers sitted side by side are eating at the same time!");
    if (phers[0]==EATING && phers[PHER_NUM-1]==EATING){
    System.err.println("0 and "+PHER_NUM+"two of philosophers sitted side by side are eating at the same time!");
    public static void main(String[] args) {
    for (int i = 0; i < PHER_NUM; i++) {
    PhilosopherEating.pherState[i] = THINKING;
    PhilosopherEating aPhilosopherEating = new PhilosopherEating();
    for (int i = 0; i < PHER_NUM; i++) {
    philosophers[i] = new Philosopher(i);
    philosophers[i].start();
    try {
    Thread.sleep(30000);
    catch (InterruptedException ex) {
    ex.printStackTrace(System.out);
    //End all the threads of philosophers
    PhilosopherEating.finished = true;

    this problem is about learning how to use threads/synchronise objects etc, the efficiency of the code isn't really an issue, if that's what you mean. As for the efficiency of the solution, it's very hard to tell how efficient it is, but as long as all the philosphers get to eat there's no problem. I haven't really scrutized your code, but I'm not sure that you have a deadlock free solution: as long as it is possible for all the phils to pick up one fork at the same time there's a problem, and it seems from your code that each philosopher will pick up "his" fork. Again, I could be wrong, I haven't really looked. If you haven't come up with a solution, try drawing it on paper and working it out, or if you're lazy a quick google will probably give you the answer, but I'm pretty sure nobody here will :)

  • Java.lang.thread exception while using Xalan 2.0 in WLS 6.0

    Hi, I'm trying to use Xalan 2.0 in a servlet hosted by WLS. Ive
    modified Xalan's SimpleTransform sample to be a servlet. I
    create a Transformer with the .xsl, then call tranform() to
    print the tranformed xml to the response stream. The xml is
    tranformed correctly, but it throws a java.lang.thread
    exception. The standalone Xalan sample doesn't do this. Anyone
    else seen this problem?
    Here's the code of interestest, I apologize if its not formatted very well:
    public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException
         PrintWriter out = res.getWriter();
         res.setContentType("text/html");
         out.println("<html><head><title>XalanTest<title></head>");
         out.println("<body><h1>XalanTest</h1>");
         try{
         TransformerFactory tFactory = TransformerFactory.newInstance();
         StreamSource ss = new StreamSource("file:\\\\My-path\\birds.xsl");
         Transformer transformer = tFactory.newTransformer(ss);
         StreamResult SR = new StreamResult(out);
         transformer.transform(new StreamSource("file:\\\\My-path\\birds.xml"), SR );
         catch(Exception e){
         out.println("<p>" + e.toString() + "</p>");
         e.printStackTrace(out);
         out.println("<p>Exception</p>");
              out.println("</body></html>");

    It also looks like the workaround suggested does not work.
    I put the following code as workaround:
         response.setContentType("text/html");
         response.setHeader ("Pragma", "no-cache");
         Transformer transformer;
         TransformerFactory factory = TransformerFactory.newInstance();
         String stylesheet = "config\\closs\\applications\\webroot\\jsp\\example\\Load2.xsl";
         String sourceId = "config\\closs\\applications\\webroot\\jsp\\example\\Load2.xml";
         String outputFile = "config\\closs\\applications\\webroot\\jsp\\example\\Load2.html";
         String outputDirectFile = "config\\closs\\applications\\webroot\\jsp\\example\\Load2_Direct.html";
         try
              PrintWriter fout = new PrintWriter (new FileOutputStream (outputFile));
              OutputStream os = new ByteArrayOutputStream();
              transformer = factory.newTransformer(new StreamSource(stylesheet));
              transformer.transform(new StreamSource(sourceId), new StreamResult(outputDirectFile));
              transformer.transform(new StreamSource(sourceId), new StreamResult(os));
              os.flush ();
              os.close();
              out.print(os.toString());
              fout.print (os.toString ());
              fout.flush ();
              fout.close ();
         catch (Exception e)
              // Error Handler
         e.printStackTrace();
    The two .html files produced look exactly the same, which is good.
    However, the screen output to my html browser (Internet Explorer 5.50 sp1) produces
    different output.
    That is strange, but that shows that this bug does not have a known workaround
    "Rabinowitz" <[email protected]> wrote:
    >
    I have the same problem with java sun xml parser (jaxp 1-1)
    It is interesting to know that all this perfectly works under weblogic
    5.1, so
    I cannot migrate my application to 6.0
    So, the functionality of weblogic 6.0 degraded since 5.1.
    I cannot buy the explanation that that is not bea's fault, because it
    perfectly
    worked with the same version of xml parser.
    Now, their customer support is saying they have not decided whether this
    is a
    bug or a feature.
    Interesting to know that degradation of functionality could be a feature!
    It is now June 21, 3 months since this bug was reported, sp2 was shipped
    since
    that time, and this bug is still there.
    "Chuck H. Zhao" <[email protected]> wrote:
    I am having the exact same problem you are having. If we analyze the
    stack
    trace:
    javax.xml.transform.TransformerException: java.lang.Thread
    at
    org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.j
    ava:1212)
    at
    org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:2894)
    at java.lang.Thread.run(Thread.java:484)
    java.lang.ClassCastException: java.lang.Thread
    at
    weblogic.servlet.internal.ResponseHeaders.setDateHeader(ResponseHeaders.java
    :273)
    at
    weblogic.servlet.internal.ServletResponseImpl.setDateHeader(ServletResponseI
    mpl.java:449)
    at
    weblogic.servlet.internal.ServletResponseImpl.writeHeaders(ServletResponseIm
    pl.java:637)
    at
    weblogic.servlet.internal.ServletOutputStreamImpl.flush(ServletOutputStreamI
    mpl.java:124)
    at
    weblogic.servlet.internal.WLOutputStreamWriter.flush(WLOutputStreamWriter.ja
    va:124)
    at java.io.PrintWriter.flush(PrintWriter.java:120)
    at
    org.apache.xalan.serialize.SerializerToXML.flushWriter(SerializerToXML.java:
    1431)
    at
    org.apache.xalan.serialize.SerializerToXML.endDocument(SerializerToXML.java:
    629)
    at
    org.apache.xalan.transformer.ResultTreeHandler.endDocument(ResultTreeHandler
    ..java:180)
    at
    org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.j
    ava:1194)
    at
    org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:2894)
    at java.lang.Thread.run(Thread.java:484)
    What happened is: to support incremental output, Xalan-Java performs
    the
    transformation in a second thread while building the source tree inthe
    main
    thread. So Transformer.transform() creates a new thread to run the
    transformer.run() method, which will write to weblogic's internal
    ServletOutputStreamImpl, and in the end calls flush() on it.
    ServletOutputStreamImpl determines that the headers haven't been written
    yet, and the headers need to be written before any servlet output, so
    it
    calls ServletResponseImpl.writeHeaders(), which eventually calls
    ResponseHeaders.setDateHeader(). The last method assumes the thread
    is
    weblogic's internal ExecuteThread and tries to cast the thread as such,
    maybe to get the date from it. But the thread is a plain java.lang.Thread
    created by xalan, thus we get the java.lang.ClassCastException:
    java.lang.Thread
    This suggests a second workaround: call ServletResponse.flushBuffer()
    before any xalan stuff, which will force the headers to be written in
    weblogic's ExecuteThread. The shortcoming of this is that this will
    cause
    the response to be commited, and if the xalan stuff throws exception
    you can
    not forward to another page.
    Another thing is that xalan should not directly call flush() on
    ServletOutputStreamImpl at all. I will report it to xalan and see if
    they
    consider that a bug. If they fix that then we have a third workaround:
    set
    the buffer size of ServletResponse big enough to accomodate everything
    including the xslt outputs, so the ServletOutput does not need to be
    flushed
    during xalan code.
    I do not consider this problem a weblogic bug, since the servlet container
    has to right to expect any thread inside it to be its own. Serlvet2.2
    spec
    says:
    1.2 What is a Servlet Container?
    A Servlet Container may place security restrictions on the environment
    that
    a servlet executes in. In
    a Java 2 Platform Standard Edition 1.2 (J2SE) or Java 2 Platform Enterprise
    Edition 1.2 (J2EE)
    environment, these restrictions should be placed using the permission
    architecture defined by Java 2
    Platform. For example, high end application servers may limit certain
    action, such as the creation of
    a Thread object, to insure that other components of the container are
    not
    negatively impacted.
    Weblogic should explicitly warn the developers that creating threads
    inside
    the servlet container may have adverse effects, the same kind of problem
    we
    are having. (or maybe they already did somewhere in their documentation?)
    On the xalan side, I would suggest them to either give the option to
    switch
    the two threads, or to give the option to buffer the output and write
    it out
    in the main thread, which is exactly what you did in your first workaround.
    Any comments or thoughts on the subject are welcome.
    -- Chuck Zhao
    "MK Parini" <[email protected]> wrote in message
    news:[email protected]...
    I found, what I think to be a bug, and a work-around for it.
    When doing an XSLT Transformation, you must specify a StreamResult
    to which to write the output. I was doing my transformation in
    a
    servlet so I was writing my output to the HttpResponse
    (The variable res is a javax.servlet.http.HttpServletResponse
    object)
    StreamResult htmlTarget = new StreamResult(res.getWriter());
    If I use this, when I perform the transformation using the TRAX
    APIs,
    InputStream xslFile = context.getResourceAsStream(fileName);
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Templates xslTemplates = tFactory.newTemplates(new StreamSource(xslFile));
    transformer = xslTemplates.newTransformer();
    transformer.transform(xmlSource, htmlTarget);
    I receive the ClassCastException from the class
    weblogic.servlet.internal.ResponseHeaders.setDateHeader(ResponseHeaders.java
    :273),
    as seen in my previous posting.
    I discovered, if I write my output to a StringBuffer, and then
    I write
    the StringBuffer to the HttpResponse, I do not get the ClassCastException.
    For example,
    StringWriter myWriter = new StringWriter(2400);
    StreamResult htmlTarget = new StreamResult(myWriter);
    <Same transformation code as above>
    myWriter.close();
    PrintWriter out = res.getWriter();
    out.print(myWriter.toString());
    Is this a bug in the weblogic internal servlet class or am I just
    missing something?
    Also, one concern that I have with the workaround is that it might
    hurt performance.
    Any comments or thoughts on the subject are welcome.

  • How to run two threads simultaneously ....?

    Hello All,
    I Am developing an application which send some data to server and from remote place that data is fetched and displayed.
    For this i am using Java Servlet as a server which accepts data by readObject() method of object output stream and writes using writeObject() method.
    At remote end i am fetching the data and printing that using thread.Data is fetched using URL's method
    URL urlServlet = new URL("URL of servlet");
    URLConnection con = urlServlet.openConnection();But while fetching it takes some time say 1-2sec because of that my display is not continuous.
    I want to write an application such that two threads will be running(in synchronization),second thread will start after few ms of 1st thread.One thread will continuously fetches data and other will display, so that there will be no delay at all while displaying of data.
    How to do this?
    Thanks In Advance.

    Google on: java producer consumer example
    Kaj

  • Client Synchronization Problem

    Hi All,
    When I am synchronizing for the first time to get deviceid from mobile client
    getting the following error.
    • Synchronization started 
    • Proxy http://xyz:port/meSync/servlet/meSync?~sysid=ABC& 
    • Connection to server failed. 
    • Synchronization problems: Transport-layer (http) sync exception raised (root cause: Exception while synchronizing (java.io.IOException: Not in GZIP format)) 
    Could anybody tell what  I have to do please.
    Regards,
    Ameer Baba

    Hi Abhijit,
    Here it is.
    Trace   
    [20070219 08:57:53:791] I [MI/API/Logging ] ***** LOG / TRACE SWITCHED ON 
    [20070219 08:57:53:791] I [MI/API/Logging ] ***** Mobile Engine version: MI 70 SP 9 Patch 5 Build 200612061055 
    [20070219 08:57:53:791] I [MI/API/Logging ] ***** Current timezone: Indian/Reunion 
    [20070219 08:57:53:791] I [MI ] Trace severity: All (1000) 
    [20070219 08:57:53:791] D [MI/PIOS ] No implementations found. Error Code:(3) 
    [20070219 08:57:53:791] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:dispatch request to '/jsp/trace/trace.jsp' 
    [20070219 08:57:59:808] D [MI/Core ] Set current application to 'MOBILEENGINE_JSP' 
    [20070219 08:57:59:808] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:doGet(...) called 
    [20070219 08:57:59:808] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:getEvent() done with event name = '' 
    [20070219 08:57:59:808] I [MI/API/Sync ] Terminate connection feature is not configured 
    [20070219 08:57:59:808] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:dispatch request to '/jsp/home/home.jsp' 
    [20070219 08:58:01:569] D [MI/Core ] Set current application to 'MOBILEENGINE_JSP' 
    [20070219 08:58:01:569] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:doGet(...) called 
    [20070219 08:58:01:569] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:getEvent() done with event name = '' 
    [20070219 08:58:01:569] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:dispatch request to '/jsp/home/syncpassword.jsp' 
    [20070219 08:58:06:432] D [MI/Core ] Set current application to 'MOBILEENGINE_JSP' 
    [20070219 08:58:06:432] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:doGet(...) called 
    [20070219 08:58:06:432] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:getEvent() done with event name = '' 
    [20070219 08:58:06:432] P [MI/Sync ] Notify R3 called 
    [20070219 08:58:06:432] D [MI/Sync ] There is already a container for method WAF_REGISTRY and user AMEERB in the outbound queue 
    [20070219 08:58:06:432] I [MI/API/Sync ] Terminate connection feature is not configured 
    [20070219 08:58:06:432] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:dispatch request to '/jsp/home/home.jsp' 
    [20070219 08:58:06:447] D [MI/API/Services ] MEResourceBundle:Constructor: Create MEResourceBundle(com/sap/ip/me/awtapps/home/mobile_engine, en_IN, (null)) 
    [20070219 08:58:06:447] D [MI/API/Services ] MEResourceBundle:Constructor: Use classloader com.sap.ip.me.core.Startup@18fe7c3 
    [20070219 08:58:06:447] D [MI/API/Services ] CREATED MEPropertyResourceBundle com.sap.ip.me.api.services.MEResourceBundle$MEPropertyResourceBundle@d24e3f for bundleName: com/sap/ip/me/awtapps/home/mobile_engine with Locale: _en 
    [20070219 08:58:06:463] D [MI/API/Services ] CREATED parent MEPropertyResourceBundle for child bundle: com.sap.ip.me.api.services.MEResourceBundle$MEPropertyResourceBundle@d24e3f using bundle name: com/sap/ip/me/awtapps/home/mobile_engine 
    [20070219 08:58:06:463] I [MI/Sync ] Synchronize with backend called, Thread=Thread-27 
    [20070219 08:58:06:463] I [MI/Sync ] Thread=Thread-27 took lock for synchronization. 
    [20070219 08:58:06:463] P [MI/Sync ] Use following gateway for synchronization: http://cymobile:8001 
    [20070219 08:58:06:588] D [MI/SyncMonitor ] New synchronization process has been started 
    [20070219 08:58:06:588] D [MI/Sync ] Synchronisation: Fire SyncEvent 0 
    [20070219 08:58:06:588] D [MI/API/Services ] MEResourceBundle:Constructor: Create MEResourceBundle(com/sap/ip/me/awtapps/home/mobile_engine, en_IN, (null)) 
    [20070219 08:58:06:588] D [MI/API/Services ] MEResourceBundle:Constructor: Use classloader com.sap.ip.me.core.Startup@18fe7c3 
    [20070219 08:58:06:588] D [MI/API/Services ] CREATED MEPropertyResourceBundle com.sap.ip.me.api.services.MEResourceBundle$MEPropertyResourceBundle@10f41e9 for bundleName: com/sap/ip/me/awtapps/home/mobile_engine with Locale: _en 
    [20070219 08:58:06:603] D [MI/API/Services ] CREATED parent MEPropertyResourceBundle for child bundle: com.sap.ip.me.api.services.MEResourceBundle$MEPropertyResourceBundle@10f41e9 using bundle name: com/sap/ip/me/awtapps/home/mobile_engine 
    [20070219 08:58:06:603] D [MI/API/Sync ] SyncEvent com.sap.ip.me.api.sync.SyncEvent[source=com.sap.ip.me.sync.SyncManagerMerger@5bb966] skipped for User because he has not been installed on MW. 
    [20070219 08:58:06:603] D [MI/API/Sync ] SyncEvent com.sap.ip.me.api.sync.SyncEvent[source=com.sap.ip.me.sync.SyncManagerMerger@5bb966] skipped for User because he has not been installed on MW. 
    [20070219 08:58:06:603] D [MI/API/Sync ] SyncEvent com.sap.ip.me.api.sync.SyncEvent[source=com.sap.ip.me.sync.SyncManagerMerger@5bb966] skipped for User because he has not been installed on MW. 
    [20070219 08:58:06:603] D [MI/API/Sync ] SyncEvent com.sap.ip.me.api.sync.SyncEvent[source=com.sap.ip.me.sync.SyncManagerMerger@5bb966] skipped for User because he has not been installed on MW. 
    [20070219 08:58:06:603] D [MI/API/Sync ] SyncEvent com.sap.ip.me.api.sync.SyncEvent[source=com.sap.ip.me.sync.SyncManagerMerger@5bb966] skipped for User because he has not been installed on MW. 
    [20070219 08:58:06:603] D [MI/API/Sync ] SyncEvent com.sap.ip.me.api.sync.SyncEvent[source=com.sap.ip.me.sync.SyncManagerMerger@5bb966] skipped for User because he has not been installed on MW. 
    [20070219 08:58:06:603] D [MI/API/Sync ] SyncEvent com.sap.ip.me.api.sync.SyncEvent[source=com.sap.ip.me.sync.SyncManagerMerger@5bb966] skipped for User because he has not been installed on MW. 
    [20070219 08:58:06:603] D [MI/API/Sync ] SyncEvent com.sap.ip.me.api.sync.SyncEvent[source=com.sap.ip.me.sync.SyncManagerMerger@5bb966] skipped for User because he has not been installed on MW. 
    [20070219 08:58:06:603] D [MI/API/Sync ] SyncEvent com.sap.ip.me.api.sync.SyncEvent[source=com.sap.ip.me.sync.SyncManagerMerger@5bb966] skipped for User because he has not been installed on MW. 
    [20070219 08:58:06:603] P [MI/Sync ] Start updating data completeness flag for user all sync relevant users 
    [20070219 08:58:06:634] P [MI/Sync ] Update data completeness flag for user AMEERB 
    [20070219 08:58:06:634] P [MI/Sync ] Update data completeness flag for user (SHARED) 
    [20070219 08:58:06:634] P [MI/Sync ] Finished updating data completeness flag for user all sync relevant users 
    [20070219 08:58:06:634] P [MI/Sync ] Repetitive sync is turned off 
    [20070219 08:58:06:634] P [MI/Sync ] Synchronization started for user (SHARED) 
    [20070219 08:58:06:634] D [MI/API/Services ] MEResourceBundle:Constructor: Create MEResourceBundle(com/sap/ip/me/awtapps/home/mobile_engine, en_IN, (null)) 
    [20070219 08:58:06:634] D [MI/API/Services ] MEResourceBundle:Constructor: Use classloader com.sap.ip.me.core.Startup@18fe7c3 
    [20070219 08:58:06:634] D [MI/API/Services ] CREATED MEPropertyResourceBundle com.sap.ip.me.api.services.MEResourceBundle$MEPropertyResourceBundle@b05acd for bundleName: com/sap/ip/me/awtapps/home/mobile_engine with Locale: _en 
    [20070219 08:58:06:634] D [MI/API/Services ] CREATED parent MEPropertyResourceBundle for child bundle: com.sap.ip.me.api.services.MEResourceBundle$MEPropertyResourceBundle@b05acd using bundle name: com/sap/ip/me/awtapps/home/mobile_engine 
    [20070219 08:58:06:634] D [MI/SyncMonitor ] Sync monitor data file does not exist; use default values 
    [20070219 08:58:06:634] D [MI/SyncMonitor ] Start sync cycle at 20070219085806 (1171875486634) 
    [20070219 08:58:06:634] D [MI/Sync ] PackageManager: old package file C:\Program Files\SAP Mobile Infrastructure\sync\(SHARED)\out\package.out was successfully deleted 
    [20070219 08:58:06:634] D [MI/Sync ] PackageManager: create package with maximum 2147483647 items 
    [20070219 08:58:06:650] D [MI/API/Services ] MEResourceBundle:Constructor: Create MEResourceBundle(com/sap/ip/me/awtapps/home/mobile_engine, en_IN, (null)) 
    [20070219 08:58:06:650] D [MI/API/Services ] MEResourceBundle:Constructor: Use classloader com.sap.ip.me.core.Startup@18fe7c3 
    [20070219 08:58:06:650] D [MI/API/Services ] CREATED MEPropertyResourceBundle com.sap.ip.me.api.services.MEResourceBundle$MEPropertyResourceBundle@1989b5 for bundleName: com/sap/ip/me/awtapps/home/mobile_engine with Locale: _en 
    [20070219 08:58:06:650] D [MI/API/Services ] CREATED parent MEPropertyResourceBundle for child bundle: com.sap.ip.me.api.services.MEResourceBundle$MEPropertyResourceBundle@1989b5 using bundle name: com/sap/ip/me/awtapps/home/mobile_engine 
    [20070219 08:58:06:650] D [MI/Sync ] PackageManager: filled package with 0 acknowledge received container(s) 
    [20070219 08:58:06:650] D [MI/API/Services ] MEResourceBundle:Constructor: Create MEResourceBundle(com/sap/ip/me/awtapps/home/mobile_engine, en_IN, (null)) 
    [20070219 08:58:06:650] D [MI/API/Services ] MEResourceBundle:Constructor: Use classloader com.sap.ip.me.core.Startup@18fe7c3 
    [20070219 08:58:06:650] D [MI/API/Services ] CREATED MEPropertyResourceBundle com.sap.ip.me.api.services.MEResourceBundle$MEPropertyResourceBundle@a00185 for bundleName: com/sap/ip/me/awtapps/home/mobile_engine with Locale: _en 
    [20070219 08:58:06:666] D [MI/API/Services ] CREATED parent MEPropertyResourceBundle for child bundle: com.sap.ip.me.api.services.MEResourceBundle$MEPropertyResourceBundle@a00185 using bundle name: com/sap/ip/me/awtapps/home/mobile_engine 
    [20070219 08:58:06:666] D [MI/Sync ] PackageManager: filled package with 0 acknowledge container(s) 
    [20070219 08:58:06:666] D [MI/API/Services ] MEResourceBundle:Constructor: Create MEResourceBundle(com/sap/ip/me/awtapps/home/mobile_engine, en_IN, (null)) 
    [20070219 08:58:06:666] D [MI/API/Services ] MEResourceBundle:Constructor: Use classloader com.sap.ip.me.core.Startup@18fe7c3 
    [20070219 08:58:06:666] D [MI/API/Services ] CREATED MEPropertyResourceBundle com.sap.ip.me.api.services.MEResourceBundle$MEPropertyResourceBundle@c3c315 for bundleName: com/sap/ip/me/awtapps/home/mobile_engine with Locale: _en 
    [20070219 08:58:06:666] D [MI/API/Services ] CREATED parent MEPropertyResourceBundle for child bundle: com.sap.ip.me.api.services.MEResourceBundle$MEPropertyResourceBundle@c3c315 using bundle name: com/sap/ip/me/awtapps/home/mobile_engine 
    [20070219 08:58:06:666] D [MI/Sync ] PackageManager: filled package with 0 container items or headers 
    [20070219 08:58:06:666] D [MI/Sync ] PackageManager: filled package with 1 notify container(s) 
    [20070219 08:58:06:666] D [MI/SyncMonitor ] Finished outbound preparation at 20070219085806 (1171875486666) 
    [20070219 08:58:06:666] D [MI/Sync ] Package file C:\Program Files\SAP Mobile Infrastructure\sync\(SHARED)\out\package.out exists and can be read 
    [20070219 08:58:06:666] P [MI/Sync ] Synchronisation started 
    [20070219 08:58:06:666] D [MI/Sync ] Begin: Dumping file C:\Program Files\SAP Mobile Infrastructure\sync\(SHARED)\out\package.out 
    <ID>MISYNC</ID><FLAGS>0x1</FLAGS><VERSION>251500</VERSION> 
    <CONTAINER> 
    <HEADER> 
    <CONTAINER_ID>0110d938dbcae8b4c559</CONTAINER_ID> 
    <OWNER></OWNER> 
    <CONTAINER_TYPE>N</CONTAINER_TYPE> 
    <METHOD></METHOD> 
    <CONVERSATION_ID></CONVERSATION_ID> 
    <PARENT_CONTAINER_ID></PARENT_CONTAINER_ID> 
    <MESSAGE_INDEX>-1</MESSAGE_INDEX> 
    <MESSAGE_TYPE> </MESSAGE_TYPE> 
    <SERVER_ID>NEW_PROTOCOL</SERVER_ID> 
    <BODY_TYPE></BODY_TYPE> 
    <BODY_LENGTH>0</BODY_LENGTH> 
    <SUB_CONTAINER_ID>-1</SUB_CONTAINER_ID> 
    <SUB_CONT_MAX>0</SUB_CONT_MAX> 
    <ITEM_FROM>-1</ITEM_FROM> 
    <ITEM_TO>-1</ITEM_TO> 
    </HEADER> 
    </CONTAINER> 
    <SYNC_MONITOR> 
    <NEW_SYNC_FLAG>1</NEW_SYNC_FLAG> 
    <OUTBOUND_PREPARATION_TIME>0</OUTBOUND_PREPARATION_TIME> 
    <OUTBOUND_PREPARATION_FINISHED>20070219085806</OUTBOUND_PREPARATION_FINISHED> 
    <LAST_SERVER2CLIENT_NETWORK_TIME>-2147483648</LAST_SERVER2CLIENT_NETWORK_TIME> 
    <LAST_INBOUND_PROCESSING_TIME>-2147483648</LAST_INBOUND_PROCESSING_TIME> 
    <LAST_SYNC_CYCLE_TIME>-2147483648</LAST_SYNC_CYCLE_TIME> 
    <LAST_SYNC_GUID></LAST_SYNC_GUID> 
    </SYNC_MONITOR> 
    [20070219 08:58:06:681] D [MI/Sync ] End: Dumping file C:\Program Files\SAP Mobile Infrastructure\sync\(SHARED)\out\package.out 
    [20070219 08:58:06:681] I [MI/Sync ] Outbound file size for user (SHARED) is 131 
    [20070219 08:58:06:681] P [MI/Sync ] Do not use http proxy (system properties update) 
    [20070219 08:58:06:681] P [MI/Sync ] Use following gateway for synchronization: http://cymobile:8001 
    [20070219 08:58:06:681] I [MI/Sync ] GzipDataCompression: Gzip data compression is switched on 
    [20070219 08:58:06:681] P [MI/Sync ] Sending outbound file compressed to server. 
    [20070219 08:58:06:681] P [MI/Sync ] Outbound file was compressedly sent. 
    [20070219 08:58:06:697] I [MI/Sync ] HttpSynchronizer caught exception java.io.FileNotFoundException: http://name:port/sap/bc/MJC/mi_host?sysid=XYZ&client=100&~language=EN&ACKNOWLEDGE=& 
    java.io.FileNotFoundException: http://name:port/sap/bc/MJC/mi_host?sysid=XYZ&client=100&~language=EN&ACKNOWLEDGE=& 
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:812) 
    at com.sap.ip.me.sync.HTTPSynchronizer.getInputStreamViaTimeOutOrNot(HTTPSynchronizer.java:351) 
    at com.sap.ip.me.sync.HTTPSynchronizer.synchronize(HTTPSynchronizer.java:258) 
    at com.sap.ip.me.sync.HTTPSynchronizer.synchronize(HTTPSynchronizer.java:484) 
    at com.sap.ip.me.sync.HTTPSynchronizer.exchangeData(HTTPSynchronizer.java:73) 
    at com.sap.ip.me.sync.SyncManagerImpl.processSyncCycle(SyncManagerImpl.java:847) 
    at com.sap.ip.me.sync.SyncManagerImpl.syncForUser(SyncManagerImpl.java:1304) 
    at com.sap.ip.me.sync.SyncManagerImpl.processSynchronization(SyncManagerImpl.java:935) 
    at com.sap.ip.me.sync.SyncManagerImpl.synchronizeWithBackend(SyncManagerImpl.java:440) 
    at com.sap.ip.me.sync.SyncManagerImpl.synchronizeWithBackend(SyncManagerImpl.java:303) 
    at com.sap.ip.me.api.sync.SyncManager.synchronizeWithBackend(SyncManager.java:79) 
    at com.sap.ip.me.apps.jsp.Home$SyncRunnable.run(Home.java:568) 
    at java.lang.Thread.run(Thread.java:534) 
    [20070219 08:58:06:697] E [MI/Sync ] Exception while synchronizing via http 
    com.sap.ip.me.api.services.HttpConnectionException: Exception while synchronizing (java.io.FileNotFoundException: http://name:port/sap/bc/MJC/mi_host?sysid=XYZ&client=100&~language=EN&ACKNOWLEDGE=&) 
    at com.sap.ip.me.sync.HTTPSynchronizer.synchronize(HTTPSynchronizer.java:334) 
    at com.sap.ip.me.sync.HTTPSynchronizer.synchronize(HTTPSynchronizer.java:484) 
    at com.sap.ip.me.sync.HTTPSynchronizer.exchangeData(HTTPSynchronizer.java:73) 
    at com.sap.ip.me.sync.SyncManagerImpl.processSyncCycle(SyncManagerImpl.java:847) 
    at com.sap.ip.me.sync.SyncManagerImpl.syncForUser(SyncManagerImpl.java:1304) 
    at com.sap.ip.me.sync.SyncManagerImpl.processSynchronization(SyncManagerImpl.java:935) 
    at com.sap.ip.me.sync.SyncManagerImpl.synchronizeWithBackend(SyncManagerImpl.java:440) 
    at com.sap.ip.me.sync.SyncManagerImpl.synchronizeWithBackend(SyncManagerImpl.java:303) 
    at com.sap.ip.me.api.sync.SyncManager.synchronizeWithBackend(SyncManager.java:79) 
    at com.sap.ip.me.apps.jsp.Home$SyncRunnable.run(Home.java:568) 
    at java.lang.Thread.run(Thread.java:534) 
    [20070219 08:58:06:697] P [MI/Core ] original context restored 
    [20070219 08:58:06:697] W [MI/Sync ] Synchronisation problems 
    com.sap.ip.me.api.sync.SyncException: Transport-layer (http) sync exception raised (root cause: Exception while synchronizing (java.io.FileNotFoundException: http://name:port/sap/bc/MJC/mi_host?sysid=XYZ&client=100&~language=EN&ACKNOWLEDGE=&)) 
    at com.sap.ip.me.sync.HTTPSynchronizer.exchangeData(HTTPSynchronizer.java:82) 
    at com.sap.ip.me.sync.SyncManagerImpl.processSyncCycle(SyncManagerImpl.java:847) 
    at com.sap.ip.me.sync.SyncManagerImpl.syncForUser(SyncManagerImpl.java:1304) 
    at com.sap.ip.me.sync.SyncManagerImpl.processSynchronization(SyncManagerImpl.java:935) 
    at com.sap.ip.me.sync.SyncManagerImpl.synchronizeWithBackend(SyncManagerImpl.java:440) 
    at com.sap.ip.me.sync.SyncManagerImpl.synchronizeWithBackend(SyncManagerImpl.java:303) 
    at com.sap.ip.me.api.sync.SyncManager.synchronizeWithBackend(SyncManager.java:79) 
    at com.sap.ip.me.apps.jsp.Home$SyncRunnable.run(Home.java:568) 
    at java.lang.Thread.run(Thread.java:534) 
    [20070219 08:58:06:697] D [MI/Sync ] Synchronisation: Fire SyncEvent 1 
    [20070219 08:58:06:697] D [MI/API/Services ] MEResourceBundle:Constructor: Create MEResourceBundle(com/sap/ip/me/awtapps/home/mobile_engine, en_IN, (null)) 
    [20070219 08:58:06:697] D [MI/API/Services ] MEResourceBundle:Constructor: Use classloader com.sap.ip.me.core.Startup@18fe7c3 
    [20070219 08:58:06:697] D [MI/API/Services ] CREATED MEPropertyResourceBundle com.sap.ip.me.api.services.MEResourceBundle$MEPropertyResourceBundle@1328c7a for bundleName: com/sap/ip/me/awtapps/home/mobile_engine with Locale: _en 
    [20070219 08:58:06:697] D [MI/API/Services ] CREATED parent MEPropertyResourceBundle for child bundle: com.sap.ip.me.api.services.MEResourceBundle$MEPropertyResourceBundle@1328c7a using bundle name: com/sap/ip/me/awtapps/home/mobile_engine 
    [20070219 08:58:06:697] P [MI/Core ] Thread Thread-27 switched context to MI414d45455242 / MI414d45455242 (User: AMEERB, MSD: Name: / MOBILEENGINE_JSP (V. 7095), Target=, Type=com.sap.ip.me.core.FrameworkApplicationType) (stack level 1) 
    [20070219 08:58:06:697] I [MI/API/Sync ] SyncEvent Performing com.sap.ip.mi.systemnews.SyncListener on ConversationId MI414d45455242 
    [20070219 08:58:06:697] P [MI/Core ] original context restored 
    [20070219 08:58:06:697] P [MI/Core ] Thread Thread-27 switched context to MI2853484152454429 / MI2853484152454429 (User: (SHARED), MSD: Name: / MOBILEENGINE_JSP (V. 7095), Target=, Type=com.sap.ip.me.core.FrameworkApplicationType) (stack level 1) 
    [20070219 08:58:06:697] I [MI/API/Sync ] SyncEvent Performing com.sap.ip.me.ccms.remotetracing.RemoteTracingListener on ConversationId MI2853484152454429 
    [20070219 08:58:06:697] P [MI/Core ] original context restored 
    [20070219 08:58:06:697] P [MI/Core ] Thread Thread-27 switched context to MI2853484152454429 / MI2853484152454429 (User: (SHARED), MSD: Name: / MOBILEENGINE_JSP (V. 7095), Target=, Type=com.sap.ip.me.core.FrameworkApplicationType) (stack level 1) 
    [20070219 08:58:06:697] I [MI/API/Sync ] SyncEvent Performing com.sap.ip.me.ccms.LastSuccessfulSyncAlert on ConversationId MI2853484152454429 
    [20070219 08:58:06:697] P [MI/Core ] original context restored 
    [20070219 08:58:06:697] P [MI/Core ] Thread Thread-27 switched context to MI2853484152454429 / MI2853484152454429 (User: (SHARED), MSD: Name: / MOBILEENGINE_JSP (V. 7095), Target=, Type=com.sap.ip.me.core.FrameworkApplicationType) (stack level 1) 
    [20070219 08:58:06:697] I [MI/API/Sync ] SyncEvent Performing com.sap.ip.me.ccms.AlertManagerImpl on ConversationId MI2853484152454429 
    [20070219 08:58:06:697] P [MI/Core ] original context restored 
    [20070219 08:58:06:697] P [MI/Core ] Thread Thread-27 switched context to MI2853484152454429 / MI2853484152454429 (User: (SHARED), MSD: Name: / MOBILEENGINE_JSP (V. 7095), Target=, Type=com.sap.ip.me.core.FrameworkApplicationType) (stack level 1) 
    [20070219 08:58:06:697] I [MI/API/Sync ] SyncEvent Performing com.sap.ip.me.sync.LogSender on ConversationId MI2853484152454429 
    [20070219 08:58:06:712] P [MI/Core ] original context restored 
    [20070219 08:58:06:712] P [MI/Core ] Thread Thread-27 switched context to MI2853484152454429 / MI2853484152454429 (User: (SHARED), MSD: Name: / MOBILEENGINE_JSP (V. 7095), Target=, Type=com.sap.ip.me.core.FrameworkApplicationType) (stack level 1) 
    [20070219 08:58:06:712] I [MI/API/Sync ] SyncEvent Performing com.sap.ip.me.services.os.AgentManager$AgentSyncEventListener on ConversationId MI2853484152454429 
    [20070219 08:58:06:712] P [MI/Core ] original context restored 
    [20070219 08:58:06:712] P [MI/Core ] Thread Thread-27 switched context to MI414d45455242 / MI414d45455242 (User: AMEERB, MSD: Name: / MOBILEENGINE_JSP (V. 7095), Target=, Type=com.sap.ip.me.core.FrameworkApplicationType) (stack level 1) 
    [20070219 08:58:06:712] I [MI/API/Sync ] SyncEvent Performing com.sap.ip.me.core.StatusUpdater on ConversationId MI414d45455242 
    [20070219 08:58:06:712] P [MI/Core ] original context restored 
    [20070219 08:58:06:712] P [MI/Core ] Thread Thread-27 switched context to MI2853484152454429 / MI2853484152454429 (User: (SHARED), MSD: Name: / MOBILEENGINE_JSP (V. 7095), Target=, Type=com.sap.ip.me.core.FrameworkApplicationType) (stack level 1) 
    [20070219 08:58:06:712] I [MI/API/Sync ] SyncEvent Performing com.sap.ip.me.ccms.configinfo.ConfigInfoListener on ConversationId MI2853484152454429 
    [20070219 08:58:06:712] P [MI/Core ] original context restored 
    [20070219 08:58:06:712] P [MI/Core ] Thread Thread-27 switched context to MI2853484152454429 / MI2853484152454429 (User: (SHARED), MSD: Name: / MOBILEENGINE_JSP (V. 7095), Target=, Type=com.sap.ip.me.core.FrameworkApplicationType) (stack level 1) 
    [20070219 08:58:06:712] I [MI/API/Sync ] SyncEvent Performing com.sap.ip.me.services.os.ScriptManager on ConversationId MI2853484152454429 
    [20070219 08:58:06:712] P [MI/Core ] original context restored 
    [20070219 08:58:06:712] I [MI/Sync ] Synchronization finished, Thread=Thread-27 
    [20070219 08:58:16:703] D [MI/Core ] Set current application to 'MOBILEENGINE_JSP' 
    [20070219 08:58:16:703] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:doGet(...) called 
    [20070219 08:58:16:703] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:getEvent() done with event name = '' 
    [20070219 08:58:16:703] I [MI/API/Sync ] Terminate connection feature is not configured 
    [20070219 08:58:16:703] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:dispatch request to '/jsp/home/synclog.jsp' 
    [20070219 08:58:21:317] D [MI/Core ] Set current application to 'MOBILEENGINE_JSP' 
    [20070219 08:58:21:317] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:doGet(...) called 
    [20070219 08:58:21:317] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:getEvent() done with event name = '' 
    [20070219 08:58:21:317] I [MI/API/Sync ] Terminate connection feature is not configured 
    [20070219 08:58:21:317] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:dispatch request to '/jsp/home/home.jsp' 
    [20070219 08:58:22:579] D [MI/Core ] Set current application to 'MOBILEENGINE_JSP' 
    [20070219 08:58:22:579] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:doGet(...) called 
    [20070219 08:58:22:579] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:getEvent() done with event name = '' 
    [20070219 08:58:22:579] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:dispatch request to '/jsp/trace/trace.jsp' 
    [20070219 08:58:24:684] D [MI/Core ] Set current application to 'MOBILEENGINE_JSP' 
    [20070219 08:58:24:684] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:doGet(...) called 
    [20070219 08:58:24:684] D [MI/API/Runtime/JSP ] AbstractMEHttpServlet:getEvent() done with event name = '' 
    Regards,
    Ameer Baba.

  • [WLS92] Thread synchronization bottleneck in RJVMManager

    All,
    First off, apologies for the long post -- there is a lot to get through.
    h3. Environment:
    Weblogic Server 9.2 MP3 deployed into Solaris 10 / Sparc hosts.
    Sun JDK 1.5.0_12 JVM (shipped with WLS)
    h3. Problem:
    We are experiencing a problem with out WLS 9.2/MP3 (Solaris/Sparc) installation. We have a number of servers each running the same WLS configuration but some with different application: one server is running App A, 4 other servers are running App B (not in a cluster). We are using JMS to transfer messages from App A to App B in a strict failover configuration such that App A will always try and send to App B1, App B2, AppB3 and finally App B4, moving from one to the next if the transfer fails or takes longer than a given timeout (10 seconds). The dispatching happens in separate threads, which I will refer to as 'senders', so we can timeout the transfer attempt.
    In the 'happy day' scenario where all four App B servers are up and running, everything works as expected.
    Problems start to surface when we test the failover configurations.
    In scenarios where the hosts are available but WLS is in either not running or in Admin mode, the failover proceeds as expected.
    In scenarios where the hosts are unavailable (hardware is powered down, network is disrupted etc.), the failover does not proceed as expected. In a scenario where App B1 is down but the other three are available for example, the following are observed:
    1. the time taken for the underlying socket connection to App B1 to timeout is very long (~7.5 minutes).
    2. the connections to the other hosts appear to block until after the socket timeout to App B1 occurs.
    The relevant section of the code is:
    weblogic.security.Security.runAs(new Subject(), new PrivilegedAction<Void>() {
         public Void run() {
              InitialContext context = null;
              try {
                   * During server-to-server sending of messages we must establish and maintain
                   * a new context that will contain the security information established by
                   * the initial context object. This has to be done per thread, hence why it
                   * is applied here to the dispatcher. The context will be closed when
                   * the thread is returned.
                   final Hashtable<?,?> environment = getEnvironment();
                   try {
                        if (log.isDebugEnabled()) {
                             log.debug(format("run(): Sender %d Creating initial context; env=%s", id, environment));
                        context = new InitialContext(environment);
                        if (log.isDebugEnabled()) {
                             log.debug(format("run(): Sender %d Created initial context in %d ms", id, System.currentTimeMillis() - start));
                        runWithContext();
                   } catch (NamingException e) {
                        log.error(format("run(): Sender %d cannot create initial context", id), e);
              } finally {
                   try {                           
                        if (context != null) {
                             if (log.isDebugEnabled()) {
                                  log.debug(format("run(): Sender %d closing initial context", id, context));
                             context.close();
                   } catch (NamingException e) {
                        log.error(format("run(): Sender %d cannot close initial context", id), e);
              return null;
    Thread stacks for two sample threads in this scenario are as follows. Thread '20' is the sender attempting to connect to App B1, Thread '8' is the sender attempting to connect to App B2 and is representative of a number of other threads all attempting to connect to known good hosts.
    Daemon Thread [[ACTIVE] ExecuteThread: '20' for queue: 'weblogic.kernel.Default (self-tuning)'] (Suspended)     
         PlainSocketImpl.socketConnect(InetAddress, int, int) line: not available [native method]     
         SocksSocketImpl(PlainSocketImpl).doConnect(InetAddress, int, int) line: 333     
         SocksSocketImpl(PlainSocketImpl).connectToAddress(InetAddress, int, int) line: 195     
         SocksSocketImpl(PlainSocketImpl).connect(SocketAddress, int) line: 182     
         SocksSocketImpl.connect(SocketAddress, int) line: 366     
         SSLSocketImpl(Socket).connect(SocketAddress, int) line: 519     
         SSLSocketImpl(Socket).connect(SocketAddress) line: 469     
         SSLSocketImpl(Socket).<init>(SocketAddress, SocketAddress, boolean) line: 366     
         SSLSocketImpl(Socket).<init>(InetAddress, int, InetAddress, int) line: 266     
         SSLSocketImpl(SSLSocket).<init>(InetAddress, int, InetAddress, int) line: 195     
         SSLSocketImpl.<init>(TLSSystem, InetAddress, int, InetAddress, int) line: not available     
         SSLSocketFactoryImpl.createSocket(InetAddress, int, InetAddress, int) line: not available     
         ChannelSSLSocketFactory.createSocket(InetAddress, int) line: 77     
         MuxableSocketT3S(AbstractMuxableSocket).createSocket(InetAddress, int, int) line: 207     
         MuxableSocketT3S(MuxableSocketT3).newSocketWithRetry(InetAddress, int, int) line: 252     
         MuxableSocketT3S(MuxableSocketT3).connect(InetAddress, int, int) line: 421     
         MuxableSocketT3S.createConnection(InetAddress, int, ServerChannel, JVMID, int) line: 79     
         ConnectionManager.createConnection(Protocol, InetAddress, int, ServerChannel, JVMID, int) line: 1749     
         ConnectionManagerServer(ConnectionManager).findOrCreateConnection(ServerChannel, JVMID, int) line: 1410     
         ConnectionManagerServer(ConnectionManager).bootstrap(JVMID, ServerChannel, int) line: 448     
         ConnectionManagerServer(ConnectionManager).bootstrap(InetAddress, int, ServerChannel, int) line: 326     
         RJVMManager.findOrCreateRemoteInternal(InetAddress, int, String, String, int) line: 261     
         RJVMManager.findOrCreate(InetAddress, int, String, String, int) line: 204     
         RJVMFinder.findOrCreateRemoteServer(InetAddress, int, String, int) line: 226     
         RJVMFinder.findOrCreate(boolean, String, HostID, int) line: 189     
         ServerURL.findOrCreateRJVM(boolean, String, HostID, int) line: 154     
         WLInitialContextFactoryDelegate$1.run() line: 342     
         AuthenticatedSubject.doAs(AbstractSubject, PrivilegedExceptionAction) line: 363     
         SecurityManager.runAs(AuthenticatedSubject, AuthenticatedSubject, PrivilegedExceptionAction) line: 147     
         WLInitialContextFactoryDelegate.getInitialContext(Environment, String, HostID) line: 337     
         Environment.getContext(String, HostID) line: 307     
         Environment.getContext(String) line: 277     
         WLInitialContextFactory.getInitialContext(Hashtable) line: 117     
         NamingManager.getInitialContext(Hashtable<?,?>) line: 667     
         InitialContext.getDefaultInitCtx() line: 247     
         InitialContext.init(Hashtable<?,?>) line: 223     
         InitialContext.<init>(Hashtable<?,?>) line: 197     
         FailoverMessageSender$Sender$1.run() line: 475     
         FailoverMessageSender$Sender$1.run() line: 458     
         AuthenticatedSubject.doAs(AbstractSubject, PrivilegedAction) line: 321     
         SecurityManager.runAs(AuthenticatedSubject, AuthenticatedSubject, PrivilegedAction) line: 121     
         Security.runAs(Subject, PrivilegedAction) line: 41     
         FailoverMessageSender$Sender.run() line: 457     
         DelegatingWork.run() line: 61     
         J2EEWorkManager$WorkWithListener.run() line: 259     
         ExecuteThread.execute(Runnable) line: 209     
         ExecuteThread.run() line: 181     
    Daemon Thread [[ACTIVE] ExecuteThread: '8' for queue: 'weblogic.kernel.Default (self-tuning)'] (Suspended)     
         RJVMManager.findOrCreateRemoteInternal(InetAddress, int, String, String, int) line: 252     
         RJVMManager.findOrCreate(InetAddress, int, String, String, int) line: 204     
         RJVMFinder.findOrCreateRemoteServer(InetAddress, int, String, int) line: 226     
         RJVMFinder.findOrCreate(boolean, String, HostID, int) line: 189     
         ServerURL.findOrCreateRJVM(boolean, String, HostID, int) line: 154     
         WLInitialContextFactoryDelegate$1.run() line: 342     
         AuthenticatedSubject.doAs(AbstractSubject, PrivilegedExceptionAction) line: 363     
         SecurityManager.runAs(AuthenticatedSubject, AuthenticatedSubject, PrivilegedExceptionAction) line: 147     
         WLInitialContextFactoryDelegate.getInitialContext(Environment, String, HostID) line: 337     
         Environment.getContext(String, HostID) line: 307     
         Environment.getContext(String) line: 277     
         WLInitialContextFactory.getInitialContext(Hashtable) line: 117     
         NamingManager.getInitialContext(Hashtable<?,?>) line: 667     
         InitialContext.getDefaultInitCtx() line: 247     
         InitialContext.init(Hashtable<?,?>) line: 223     
         InitialContext.<init>(Hashtable<?,?>) line: 197     
         FailoverMessageSender$Sender$1.run() line: 475     
         FailoverMessageSender$Sender$1.run() line: 458     
         AuthenticatedSubject.doAs(AbstractSubject, PrivilegedAction) line: 321     
         SecurityManager.runAs(AuthenticatedSubject, AuthenticatedSubject, PrivilegedAction) line: 121     
         Security.runAs(Subject, PrivilegedAction) line: 41     
         FailoverMessageSender$Sender.run() line: 457     
         DelegatingWork.run() line: 61     
         J2EEWorkManager$WorkWithListener.run() line: 259     
         ExecuteThread.execute(Runnable) line: 209     
         ExecuteThread.run() line: 181     
    h3. Conclusion:
    All of the threads are jamming up in RJVMManager.findOrCreateRemoteInternal(..) behind the one thread that is actually attempting to make a connection.
    A quick disassemby of the offending method class shows the following snippet:
    /* */ private RJVM findOrCreateRemoteInternal(InetAddress paramInetAddress, int paramInt1, String paramString1, String paramString2, int paramInt2)
    /* */ throws UnrecoverableConnectException, IOException
    /* 246 */ RJVM localRJVM = findExisting(paramInetAddress, paramInt1, (ServerChannel)localObject1);
    /* 248 */ if (localRJVM != null) return localRJVM;
    /* 250 */ synchronized (this.bootstrapLock)
    /* 252 */ localRJVM = findExisting(paramInetAddress, paramInt1, (ServerChannel)localObject1);
    /* 253 */ if (localRJVM != null) return localRJVM;
    /* 256 */ if ((Kernel.DEBUG) && (debugConnection.isDebugEnabled())) {
    /* 257 */ RJVMLogger.logDebug("Bootstrapping connection to: '" + paramInetAddress + ":" + paramInt1 + "' using: '" + localProtocol + "'");
    /* 260 */ ConnectionManager localConnectionManager = ConnectionManager.create(null);
    /* 261 */ return record(localConnectionManager.bootstrap(paramInetAddress, paramInt1, (ServerChannel)localObject1, paramInt2), paramInetAddress);
    Now the problem becomes clear. I suspect that the reason for the synchronized block on line 250 is to prevent two threads attempting the relatively expensive operation on line 261 (see lines 248-250 and 252-253). However, the flaw here is that the synchronization blocks all threads irrespective of which InetAddress (param 1) the thread is attempting to connect to. My personal opinion is that the monitor used for thread synchronization should be timed to the host (InetAddress) for the connection, which incidentally is used in the record(..) method anyway.
    The problem is exacerbated by the very long network connection timeout.
    h3. Solutions:
    We've tried setting the sun.net.defaultConnectTimeout JVM property to try and reduce the impact but haven't seen any noticeable improvement.
    We've tried specifying the weblogic.jndi.clientTimeout and weblogic.jndi.requestTimeout values when creating the InitialContext. For some reason specifying these properties caused all connection attempts to fail -- even the happy day scenarios.
    h3. Final Questions:
    Is this a bug? If so, what do I need to do to get this fixed urgently?
    Is this a bug other people have run into? If so, how was it resolved?
    Any other suggestions?
    Thanks!
    Edited by: user11373704 on 10-Jul-2009 08:52

    Perhaps the relevant timeouts are socket/network related in this case.
    To detect "silent" network failures, WebLogic uses a heartbeat mechanism, but I'm told that one should not tune the related settings too aggressively. I think this is tunable on a per server basis -- at least for the default network channels. Specifically there's heartbeat interval and period length on the console at "Server -> Configuration Tab --> Tuning Tab --> Advanced".
    There's also "Complete Message Timeout" under "Protocol -> General".
    In addition, TCP/IP timeouts are tunable on the operating system itself. I don't know the specifics for Solaris.
    Tom

  • A very strange synchronization problem

    Hi Everybody,
    I would like to get some help regarding a strange synchronization problem that I have found. I have created a java server application and after a lot of testing I have found the following problem:
    A certain thread (Thread-A) is stuck forever on a synchornized (objX) line, whereas another thread (Thread-B) every 30 seconds performs a section which is protected by the same synchornized (objX) line.
    It seems that the objX is not held by any thread, but Thread-A is stuck forever.
    The BUG is reproducible after the server runs about 1 day.
    The server is running on Linux machine (Red Hat 7.3) with JVM 1.4 (Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)).
    I would appreciate any help.
    Thanks In Advance,
    Idan Zach

    This is not a starvation problem since Thread-B performs its job every 30 seconds. The job is very short (I have added log messages before Thread-B starts its job and after it completes the job).
    However, the priority of both threads are the same.
    Thanks In Advance,
    Idan Zach

  • Bridge is slow because it's only using two threads

    I'm finding that Bridge (CS6) exhibits very poor performance when building 100% previews, I think the software is limited to only two threads.
    If you load bridge and go into a folder with some images and then Tools->Cache->Purge you'll see that Bridge takes a long time to rebuild the previews even on a high end machine, especially if you have both "Always High Quality" and "100% Previews" selected. I think the problem is that it appears to build the previews using only two threads on the CPU, so while a 2005 dual core machine might get maxed out, a Quad Core, or 8 Thread, or even 12 Thread machine sits there mostly idle while Bridge grinds away for an hour or more.
    It's easy to check this, just load up Windows Task Manager, and view the "Processes" tab and Bridge will only ever use 2 threads worth of CPU cycles, i.e. 50% on a Quad Core, and 17% on a 12 Thread high end desktop. I've seen the problem with JPG files, PSD files, and NEF files (Nikon RAW). The processing time of large Nikon D800E NEF files is very slow. After shooting 900 images I can expect the preview build time to take over an hour on a super high end machine with loads of memory, storage IO, and CPU cores and threads, all because it appears bottlenecked on software design. Meanwhile the machine is only running at roughly 20% utilization, the memory barely used, and the IO system close to idle.
    I'm using Windows 7 Ultimate 64-bit, 64GB RAM, 12 Thread Core i7 3960X at 4Ghz, two Nvidia GTX470 graphics (in SLI), a 2-way RAID-0 SSD storage array for the OS, and an 8-way RAID-0 SSD array for the photoshop work files. The hardware is clearly not the issue. Although, just to check, I confirmed the same problem exists on a simple Win8 Core i7 system, and a Core i5 laptop.
    Even worse, after waiting an hour to build previews for 900 images (3 seconds each), after adding GPS data, or after making edits in Camera Raw it then needs to rebuild all the previews again, this is understandable, but super fustrating when you know it's not working as fast as it really should be.
    To be clear, I'm not upset it takes 6 seconds per image per thread - there's a lot of work to do, especially with D800 files. But I'm upset that Bridge's software design only uses 2 threads, and thus limits performance to building a preview every 3 seconds, when in fact it could be working 6 times faster on a PC with 12 thread, and I find it shocking that Adobe's latest software wouldn't be optimized for anything more than a dual core CPU, wasn't quad core launched in 2006?
    Roland.
    P.S. for any Adobe Tech's reading - I submitted this under case number 184020852 and there's an attached PDF in the ticket including several screenshots.

    There have been many discussions in Photoshop forum about processor speed and multicores.  I know Bridge is not Photoshop but it may give you some insight as what is going on.  Photoshop has supported multithreading since CS3.  Here is a quote from Adobe Tech Note:
    Photoshop generally runs faster with more processor cores, although some features take greater advantage of the additional cores than others. There is a law of diminishing returns with multiple processor cores: The more cores you use, the less you get from each additional core. Therefore, Photoshop doesn’t run four times as fast on a computer with 16 processor cores as on a computer with four cores. For most users, the increase in performance that more than six cores provides doesn't justify the increased cost.
    I run embedded thumbnails (therefore 100% previews are off) as they take up less space and are the fastest to load.  I ran a simple test with Bridge CS5 (32 bit) and CS6 (64 bit) on one folder of 200 video images totaling 16 gigs, or 80 meg per file.  With folder loaded I clicked Tools/Cache/purge cache for xxx folder.  I then timed the rebuild until the arrow stopped spinning in lower left hand corner.  For CS5 the time was 35 seconds.  For CS6 the time was 72 seconds. 
    I then took a folder of 1147 jpg images of 660 meg (427k/image).  In CS5 it took 12 seconds to build the cache, and the same for CS6.  However, the interesting part of this is when I loaded this folder in CS6 I had never been there before so it had to build it.  THis took 80 seconds.  When I purged it an it rebuilt it took 12 seconds.  I have noticed this phenomemum before where the initial build takes 5-7 times longer than a rebuild of the cache.
    I then ran the same test with the still images with 100% preview and Always High Quality.  With CS5 it took 3 min 30 seconds and with CS6 it took 5 min. 20 seconds.
    So with these very SIMPLE tests I conclude that CS6 has quite a bit slower cache process than CS5.  As we have all learned with buying new products, new and improved does not always mean it is better. 

Maybe you are looking for