Synchronization problems in synchronized block

I am facing problems in the synchronizaed block similar to this :
sychronized(object)
//object manipulations
object notifyAll();
I am facing a problem when 2 requests are fired at the same time and none of them enter this block. Since this is re\lated to the server, server is getting freezed and none of the further requests are entertained.
Please help me in this.
Thanks is advance.

Thanks for all your replies.
Let me a bit more clearer about my problem.
I have
1. 2 classes which have synchronized blocks on one object of a different class
2. This object which is synchronized is shared among both the classes.
When an individual request comes, it is processes without any issues. Sometimes, when multiple requests come simultaneously when lock on the object is free, none of requests get the lock on the object. I tried putting a breakpoint where lock is provided, none of the threads are entering the synchronized block.
So at this point server is not able to entertain any of the further requests also.

Similar Messages

  • Problem with Synchronized block

    Hi,
    For me synchronized key word is not working (?) :-(
    Here is the example :
    I have three classes
    package sample.test;
    public class TestThreadMain {
         public static void main(String[] args) {
              Thread t1 = new ThreadOne();
              Thread t3 = new ThreadOne();
              t1.start();
              t3.start();
    public class TestThread {
         int k = 0;
         public synchronized void method1(){
              System.out.println("Entered into method1 >>>>>>>>>");
              for (int i=0; i<1000; i++){
                   for (int j=0; j<100000; j++){
                        k = j * 12345;
                   System.out.println("method1 i value is "+i);
    package sample.test;
    public class ThreadOne extends Thread {
         TestThread t1 = new TestThread();
         public void run() {
                   t1.method1();
    If I run "TestThreadMain" class output is
    Entered into method1 >>>>>>>>>
    method1 i value is 0
    method1 i value is 1
    method1 i value is 2
    method1 i value is 3
    method1 i value is 4
    method1 i value is 5
    method1 i value is 6
    method1 i value is 7
    method1 i value is 8
    method1 i value is 9
    method1 i value is 10
    method1 i value is 11
    method1 i value is 12
    method1 i value is 13
    method1 i value is 14
    method1 i value is 15
    method1 i value is 16
    method1 i value is 17
    method1 i value is 18
    method1 i value is 19
    method1 i value is 20
    method1 i value is 21
    method1 i value is 22
    method1 i value is 23
    method1 i value is 24
    method1 i value is 25
    method1 i value is 26
    method1 i value is 27
    method1 i value is 28
    method1 i value is 29
    method1 i value is 30
    method1 i value is 31
    method1 i value is 32
    method1 i value is 33
    method1 i value is 34
    method1 i value is 35
    method1 i value is 36
    method1 i value is 37
    method1 i value is 38
    method1 i value is 39
    method1 i value is 40
    method1 i value is 41
    method1 i value is 42
    method1 i value is 43
    method1 i value is 44
    method1 i value is 45
    method1 i value is 46
    method1 i value is 47
    method1 i value is 48
    method1 i value is 49
    method1 i value is 50
    method1 i value is 51
    method1 i value is 52
    method1 i value is 53
    method1 i value is 54
    method1 i value is 55
    method1 i value is 56
    method1 i value is 57
    method1 i value is 58
    method1 i value is 59
    method1 i value is 60
    method1 i value is 61
    method1 i value is 62
    method1 i value is 63
    method1 i value is 64
    method1 i value is 65
    method1 i value is 66
    method1 i value is 67
    method1 i value is 68
    method1 i value is 69
    method1 i value is 70
    method1 i value is 71
    method1 i value is 72
    method1 i value is 73
    method1 i value is 74
    method1 i value is 75
    method1 i value is 76
    method1 i value is 77
    method1 i value is 78
    method1 i value is 79
    method1 i value is 80
    method1 i value is 81
    method1 i value is 82
    method1 i value is 83
    method1 i value is 84
    method1 i value is 85
    method1 i value is 86
    method1 i value is 87
    method1 i value is 88
    method1 i value is 89
    method1 i value is 90
    method1 i value is 91
    method1 i value is 92
    method1 i value is 93
    method1 i value is 94
    method1 i value is 95
    method1 i value is 96
    method1 i value is 97
    method1 i value is 98
    method1 i value is 99
    method1 i value is 100
    method1 i value is 101
    method1 i value is 102
    method1 i value is 103
    method1 i value is 104
    method1 i value is 105
    method1 i value is 106
    method1 i value is 107
    method1 i value is 108
    method1 i value is 109
    method1 i value is 110
    method1 i value is 111
    method1 i value is 112
    method1 i value is 113
    method1 i value is 114
    method1 i value is 115
    method1 i value is 116
    method1 i value is 117
    method1 i value is 118
    method1 i value is 119
    method1 i value is 120
    method1 i value is 121
    method1 i value is 122
    method1 i value is 123
    method1 i value is 124
    method1 i value is 125
    method1 i value is 126
    method1 i value is 127
    method1 i value is 128
    method1 i value is 129
    method1 i value is 130
    method1 i value is 131
    method1 i value is 132
    method1 i value is 133
    method1 i value is 134
    method1 i value is 135
    method1 i value is 136
    method1 i value is 137
    method1 i value is 138
    method1 i value is 139
    method1 i value is 140
    method1 i value is 141
    method1 i value is 142
    method1 i value is 143
    method1 i value is 144
    method1 i value is 145
    method1 i value is 146
    method1 i value is 147
    method1 i value is 148
    method1 i value is 149
    method1 i value is 150
    method1 i value is 151
    method1 i value is 152
    method1 i value is 153
    method1 i value is 154
    method1 i value is 155
    method1 i value is 156
    method1 i value is 157
    method1 i value is 158
    method1 i value is 159
    method1 i value is 160
    method1 i value is 161
    method1 i value is 162
    method1 i value is 163
    method1 i value is 164
    method1 i value is 165
    method1 i value is 166
    method1 i value is 167
    method1 i value is 168
    method1 i value is 169
    method1 i value is 170
    method1 i value is 171
    method1 i value is 172
    method1 i value is 173
    method1 i value is 174
    method1 i value is 175
    method1 i value is 176
    method1 i value is 177
    method1 i value is 178
    method1 i value is 179
    method1 i value is 180
    method1 i value is 181
    method1 i value is 182
    method1 i value is 183
    method1 i value is 184
    method1 i value is 185
    method1 i value is 186
    method1 i value is 187
    method1 i value is 188
    method1 i value is 189
    method1 i value is 190
    method1 i value is 191
    method1 i value is 192
    method1 i value is 193
    method1 i value is 194
    method1 i value is 195
    method1 i value is 196
    method1 i value is 197
    method1 i value is 198
    method1 i value is 199
    method1 i value is 200
    method1 i value is 201
    method1 i value is 202
    Entered into method1 >>>>>>>>>
    method1 i value is 0
    method1 i value is 1
    method1 i value is 2
    method1 i value is 3
    method1 i value is 4
    method1 i value is 5
    method1 i value is 6
    method1 i value is 7
    method1 i value is 8
    method1 i value is 9
    method1 i value is 10
    method1 i value is 11
    method1 i value is 12
    method1 i value is 13
    method1 i value is 14
    method1 i value is 15
    method1 i value is 16
    method1 i value is 17
    method1 i value is 18
    method1 i value is 19
    method1 i value is 20
    method1 i value is 21
    method1 i value is 22
    method1 i value is 23
    method1 i value is 24
    method1 i value is 25
    method1 i value is 26
    method1 i value is 27
    method1 i value is 28
    method1 i value is 29
    method1 i value is 30
    method1 i value is 31
    method1 i value is 32 .....
    My question is as i delcared the method " method1()" as synchronized, after completion of printing the first 1000 only second thread has to enter in to this method.
    Am I wrong any where ?
    Thanks,
    Sudhakar

    1) When you post code, please use[code] and
    [/code] tags as described in
    [url=http://forum.java.sun.com/help.jspa?sec=formattin
    g]Formatting tips on the message entrypage. It makes it much easier to read.
    Sure. I will do it from next time.
    2) Was it really necessary to post 200 lines or so of
    output? Couldn't you have posted just a few to give
    us the general idea?I think it will give better understanding. So ...
    3) It's not clear to me what your question is. Are
    you saying you expected something like
    T1
    T2
    T1
    T2
    etc.
    If so, then you're mistaken. The whole point of
    multithreading is that you don't know or care which
    thread executes which instructions when. There's no
    "execute a statement then switch threads" rule. That
    would occur ridiculous amounts of overhead.As per my understanding, If one thread enters into synchronized method, the other threads needs to wait until the completion of first one.
    So, first it needs to print
    method1 i value is 1
    method1 i value is 2
    method1 i value is 1000
    then second thread should start printing.
    Is my understanding wrong or ... ?

  • Nested synchronized blocks on multiple objects without deadlock

    Is it possible? Here is an example problem that exhibits deadlock:
    public class SomeObject {
         public static class Foo {
              private int n = 0;
              public synchronized void p() {
                   n++;
                   if (n % 100 == 0)
                        System.out.print("f");
         public static class Bar {
              private int n = 0;
              public void p() {
                   n++;
                   if (n % 100 == 0)
                        System.out.print("b");
         public void doSomething1(Foo f, Bar b) {
              synchronized(f) {
                   synchronized(b) {
                        f.p();
                        b.p();
         public void doSomething2(Foo f, Bar b) {
              synchronized(b) {
                   synchronized(f) {
                        b.p();
                        f.p();
         public static void main(String[] args) {
              SomeObject so = new SomeObject();
              Foo f = new Foo();
              Bar b = new Bar();
              for (int i = 0; i < 100; i++)
                   (new MyThread(so, f, b)).start();
         public static class MyThread extends Thread {
              SomeObject so = null;
              Foo f = null;
              Bar b = null;
              public MyThread(SomeObject so, Foo f, Bar b) {
                   this.so = so;
                   this.f = f;
                   this.b = b;
              public void run() {
                   while (true) {
                        if (Math.random() > 0.5)
                             so.doSomething1(f, b);
                        else
                             so.doSomething2(f, b);
    }

    Well, playing with sinchronized code as to be done carefully.
    This is very important because de JVM does not break the deadlocks (like by throwing an exception in a deadlocked thread). so in the above example, once 2 of the threads do deadlock, the rest of the threads that are created in the main method loop will deadlock too.
    For that it is better to:
    a) use minimal sinchronized code, like in Foo.p, the method is sinchronized to have access to an internal variable.
    b) use layered sinchronization. If several components in a system have synchronized code (methods) or are used as monitors in synchronized blocks, then it is better to layer the monitor usage nesting and to eliminate circular dependencies (also it is good to minimize dependencies). This is similar to code dependency in which package circular dependency should be avoided. Though in this case it is critical.
    In the example given, the doSomething* methods generate circular dependency of monitors.
    If the desing is to have a 'transaction' in calling Foo.p() and Bar.p() from the doSomething* methods, then the usage of a 'grand-daddy' central lock would be a simple solution, like changing the doSomething* methods to:
    static public synchornized void doSomething*(Foo f, Bar b) {
    f.p();
    b.p();
    or
    public void doSomething*(Foo f, Bar b) {
    synchornized (SomeObject.class) {
    f.p();
    b.p();
    If there is no need of a 'transaction' in the calling of Foo.p() and Bar.p(), then the doSomething* methods should not have any type of synchronization, and the methods Foo.p() and Bar.p() should both be synchronized.
    Also a more complex scheme could be deviced in order to lower the contention on the SomeObject class monitor. Though for the example given, as it exists only one instance of both Foo and Bar, it is not needed.
    llongeri

  • ConcurrentModificationException in synchronized block?

    Edit: Narrowed it down to this:
    Caused by: java.util.ConcurrentModificationException: null
         at java.util.LinkedList$ListItr.checkForComodification(Unknown Source)
         at java.util.LinkedList$ListItr.next(Unknown Source)
         at server.ConversationServiceImpl.clientExit(ConversationServiceImpl.java:28)
    public void clientExit() {
         String currentUserId = getCurrentUserId();
         synchronized(users) {
              Iterator<User> it = users.iterator();
              while(it.hasNext()) {
                   User aUser;
                   synchronized(aUser = it.next()) { // Line 28
                        if(aUser.getId() == currentUserId) {
                             users.remove(aUser);
         UserList userList = new UserList(getUserListStrings());
         addEventToAllUsers(userList);
    }Surely since there is a synchronized block, there shouldn't be any ConcurrentModificationException?
    Edited by: ta2 on 29-Mar-2009 02:22

    Maxideon wrote:
    Not really. The problem was this line
    users.remove(aUser);When you are iterating through a collection you're suppose to remove elements with the iterator.
    it.remove();You also seem to be using synchronize blocks of code kind of haphazardly.
    For example in your original post you had a synchronized block around an object in local scope.
    synchronized(aUser = it.next()) {
    Yeah you're right... I don't really know what I'm doing with the synchronized blocks. Though another thread could get that particular user by going users.get(int thatOne), but I've already blocked that with the synchronized(users) bit. Is that what you mean?
    Cheers

  • Synchronized blocks: the best approach?

    I have a question concerning synchronization within a servlet. As I
              understand it, by default only one instance of a servlet will be
              instantiated by WebLogic. The impact of this is that if an instance
              variable is set in 'doGet', there is no guarantee that the value will be
              unchanged upon execution of 'doPost' (i.e. it is not "thread-safe").
              There are a few approaches to this problem, none of which are very
              appealing to me. If I utilize the "SingleThreadModel" interface, then I am
              guaranteed that the value will not change. However, this will occur at the
              expense of performance (isn't there a maximum of 5 instances?), especially
              if hundreds of users are concurrently attempting to access this same
              servlet. Even if I store a variable in the session, if the user can open
              multiple browser windows, then I could still run into a synchronization
              problem (since each window will share the same session).
              With this in mind (assuming that a user can open multiple browser windows
              and that I do not want to implement "SingleThreadModel"), is my only option
              to place synchronized blocks around the sections of code that I want
              protected?
              I appreciate any input. Thanks.
              

              It is possible to make this really messy - avoid that.
              Don't use intance variables, use only variables declared in the doGet method -
              each execution will have it's own variables and you won't have these problems.
              If you need data to persist from one call to the next, use the httpSession.
              If you need to manage separate browser windows - then put a hidden field or a
              parameter in the URL that identifies that window. Then store the data in the httpsession
              along with the window id -
              session.putValue("USERNAME_"+winId, username);
              Putting synchronized blocks doesn't really protect you from the multiple window
              problem - suppose a user does a search in one window - and the search results
              are stored in the http session. Then they do a second search in a second window
              - even if you protect the variables in a synchronize block - the second results
              will overwrite the first results. Then they start to page through what should
              be the first results in the first window - but they would see the second results.
              Mike Reiche
              Resume at http://home.earthlink.net/~mikereiche/resume.htm
              "Edward Mench" <[email protected]> wrote:
              > I have a question concerning synchronization within a servlet. As
              >I
              >understand it, by default only one instance of a servlet will be
              >instantiated by WebLogic. The impact of this is that if an instance
              >variable is set in 'doGet', there is no guarantee that the value will
              >be
              >unchanged upon execution of 'doPost' (i.e. it is not "thread-safe").
              >
              > There are a few approaches to this problem, none of which are very
              >appealing to me. If I utilize the "SingleThreadModel" interface, then
              >I am
              >guaranteed that the value will not change. However, this will occur
              >at the
              >expense of performance (isn't there a maximum of 5 instances?), especially
              >if hundreds of users are concurrently attempting to access this same
              >servlet. Even if I store a variable in the session, if the user can
              >open
              >multiple browser windows, then I could still run into a synchronization
              >problem (since each window will share the same session).
              >
              > With this in mind (assuming that a user can open multiple browser windows
              >and that I do not want to implement "SingleThreadModel"), is my only
              >option
              >to place synchronized blocks around the sections of code that I want
              >protected?
              >
              > I appreciate any input. Thanks.
              >
              >
              >
              >
              

  • IllegalMonitorStateException Thrown From Synchronized Block

    Greetings,
    We recently had a case where a java.lang.IllegalMonitorStateException was thrown from section of code (in activemq) that I'm 99.9% sure was properly synchronized. Has anyone ever seen this exception thrown when the object whose wait method is being called is currently owened (via. a synchronized block)?
    The code that this exception occurred was in the backport-util-concurrent library. A get method (which is synchronized) call was made to a FutureTask instance which (eventually) calls Object.wait(). This call threw the exception. Below is the FutureTask code.
    public synchronized Object get() throws InterruptedException, ExecutionException
      waitFor();
      return getResult();
    private void waitFor() throws InterruptedException
      while (!isDone())
        wait();
    }And the stack trace on the exception was:
    ERROR - 21/2 08:56:41 - Failed to checkpoint a message store: java.lang.IllegalMonitorStateException - org.apache.activemq.store.journal.JournalPersistenceAdapter 395
    java.lang.IllegalMonitorStateException
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:485)
    at edu.emory.mathcs.backport.java.util.concurrent.FutureTask.waitFor(FutureTask.java:267)
    at edu.emory.mathcs.backport.java.util.concurrent.FutureTask.get(FutureTask.java:117)
    at org.apache.activemq.store.journal.JournalPersistenceAdapter.doCheckpoint(JournalPersistenceAdapter.java:386)
    at org.apache.activemq.store.journal.JournalPersistenceAdapter$2.iterate(JournalPersistenceAdapter.java:129)
    at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:117)
    at org.apache.activemq.thread.PooledTaskRunner.access$100(PooledTaskRunner.java:26)
    at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:44)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
    at java.lang.Thread.run(Thread.java:619)We are running Java 1.6 on solaris (64-bit). If anybody has any feedback on what might have caused this problem it would be appreciated.
    Thanks,
    Corey

    There seem to be some difficult to reproduce bugs in JDK 6 relating to hotspot compilation (and maybe synchronization). A few threads worth checking out:
    http://forum.java.sun.com/thread.jspa?threadID=5251785&tstart=0
    http://forum.java.sun.com/thread.jspa?threadID=5262404&tstart=0
    My own bug report (this one is reproducible): http://www.blinkenbyte.org/jvm/hotspot_bug_reviewid_1085121.html
    Which reminds me, I need to get around to submitting an update to the report.. disabling HotSpot compilation on the problematic method made the problem go away in my case...
    If at all possible to turn this into a test case, please do so and submit a bug report to Sun. Somehow Sun needs to pay attention to this problem, but I haven't even got a bug id on my problem despite it being 100% reproducible.

  • Synchronized Block - Performance Issue

    Hi All,
    In my java class contains lot of synchronized methods...which in turn leads to performance issue....
    If i try to remove the synchronized methods...it leads to deadlock problem...
    Is there a way without removing the synchronized methods..to improve the performance...
    Please suggest any solution

    In my java class contains lot of synchronized methods...which in turn leads to performance issue....It causes sequentialization of critical sections of code so that they will execute correctly. You can't describe that as a performance problem unless you can show that a faster and correct implementation exists. It might: for example you could make yor synchronized blocks smaller, use concurrent data structures, etc. But what you can't do is compare it to the same code without synchronization and say it's slower. It is, but the observation has no meaning as the unsynch version isn't correct.
    If i try to remove the synchronized methods...it leads to deadlock problem...That isn't possible unless you didn't remove them all. Deadlocks result from acquiring locks in different orders.
    Is there a way without removing the synchronized methods..to improve the performance...Almost certainly. Post some code.

  • Performance of synchronized blocks on Linux much worse than on Windows

    Our application is a J2EE application currently deployed in WebLogic 6.1 which utilizes Oracle iFS as a content store. We access the iFS CMS through the api's provided in the cmdsk.jar. Our reference implementation has been Solaris and that's where most of our testing has been done so far. However, we recently began doing performance tests on Linux and ran into a strange problem. We found that we were not getting sufficient throughput and that this was coupled with underutilization of CPU resources on the Application Server (AS) node. With sufficient DB resources, which we had in this case, we expect to see full CPU utilization on the AS tier, so we knew something was wrong.
    A great deal of investigation revealed that all active threads were stuck at the same spot accessing an iFS cache. We found that this cache is implemented as a hashtable and accesses to hashtables are synchronized. However, we were not seeing the same problem on other platforms (Solaris and Windows) with dual CPU machines.
    In order to simplify things, we developed a test program to look at what we felt to be the root cause. This test program, which I will attach, essentially creates a hashtable then a number of threads (as specified by the user). These threads then use the hashtable.get method to access the hashtable concurrently and time how long it takes. The info is then returned at the end of the run.
    We ran a set of tests where we increased the number of threads from 1 to 100. This test was run once with Windows 2000 and once with Red Hat Linux 2.1 (kernel 2.4.9-e.12). The exact same hardware (dual 1.2 GHz PIII) was used in both cases. The results show that we were clearly able to reproduce the behaviour with this simple program. What these results show is that with one thread, access times are exactly the same for Windows and Linux. However, as we increase the number of threads, access times for Linux increase at a much greater rate than Windows. We also see underutilization of CPU resources on Linux while Windows uses all available.
    The first round of tests was run with Sun's JDK 1.3.1. We repeated the testing with 1.4.1 and found that there was no significant difference. I just tried it quickly with 1.4.2 and found the behaviour to be much the same. We also altered the program to use an unsynchronized hashmap instead of a hashtable and, as expected, performance on Linux was much better. CPU was fully utilized during the test.
    In order to determine if this was a problem "in the VM" or "in the kerenel", I tried repeating it with the JRocket VM provided by WebLogic. When running the same test with the JRocket VM, we saw performance roughly equivalent to what we saw with a hashmap and the Sun VM. That is, JRocket did not have the same problem as the Sun VM.
    So, it appears that there is something with the implementation of synchronized blocks in the Sun VM that is problematic, especially when compared to other platforms. It is likely that the problem lies in a combination of how the synchronization is implemention is based on the underlying operating system infrastructure. At this point, we don't really have a way to deal with the problem, aside from deploying multiple WebLogic nodes on the same 2 CPU physical AS node. Changes to the iFS infrastructure would help, but that's beyond our control. I've searched the bug database and have not seen mention of this problem. With the test program, it can be easily reproduced, but I wanted to run it by the folks on this list before submitting a bug.
    Thanks,
    Justin

    # File #1: Driver.java
    import java.io.*;
    import java.util.HashMap;
    import java.util.Hashtable;
    * Created on May 13, 2003
    * @author llai
    * Driver to test the access of hash table on various platforms.
    public class Driver
         public static void main(String[] args)
              * Obtain the following input values:
              * 1. Number of Elements
              *      - The number of elements in the hash table
              * 2. Size of Element
              * - The size of each element in the hash table
              * 3. Number of threads
              * - The number of concurrent threads in the test
              * 4. Focused Access
              * - Determines whether each thread access the same element or a random element
              * 5. Number of Accesses
              * - The number of accesses which each thread will complete before exiting
              * 6. Start offset
              * - The number of accesses at the beginning which will not be timed
              * 7. End offset
              * - The number of accesses at the end which will not be timed.
              * Initialize all input variables.
              * SET DEFAULT VALUES HERE...
              int numberOfElements = 10000;
              int sizeOfElement = 100;
              int numberOfThreads = 25;
              boolean focusedAccess = true;
              int numberOfAccesses = 1000000;
              int startOffset = 100000;
              int endOffset = 100000;
              boolean mapOrTable = false;
              * Input number of elements.
              try
                   BufferedReader in =
                        new BufferedReader(new InputStreamReader(System.in));
                   String tempInput;
                   boolean inputInvalid = true;
                   while (inputInvalid)
                        System.out.print(
                             "Enter a non-negative value for the number of elements to be in the hashtable: ");
                        tempInput = in.readLine();
                        if (tempInput.equals(""))
                             System.out.println("default value used.\n");
                             inputInvalid = false;
                        else
                             try
                                  numberOfElements = Integer.parseInt(tempInput);
                                  if (numberOfElements >= 0)
                                       inputInvalid = false;
                                  else
                                       System.out.println(
                                            "You entered a negative value for the number of elements. Try again.");
                             catch (NumberFormatException nfe)
                                  System.out.println(
                                       "You entered an invalid value for the number of elements. Try again.");
                   * Input size of elements.
                   inputInvalid = true;
                   while (inputInvalid)
                        System.out.print(
                             "Enter the size of each element in the hash table (ie. length of a string): ");
                        tempInput = in.readLine();
                        if (tempInput.equals(""))
                             System.out.println("default value used.\n");
                             inputInvalid = false;
                        else
                             try
                                  sizeOfElement = Integer.parseInt(tempInput);
                                  if (sizeOfElement >= 0)
                                       inputInvalid = false;
                                  else
                                       System.out.println(
                                            "You entered a negative value for the size of elements. Try again.");
                             catch (NumberFormatException nfe)
                                  System.out.println(
                                       "You entered an invalid value for the size of elements. Try again.");
                   * Input number of threads.
                   inputInvalid = true;
                   while (inputInvalid)
                        System.out.print(
                             "Enter the number of concurrent threads in the test: ");
                        tempInput = in.readLine();
                        if (tempInput.equals(""))
                             System.out.println("default value used.\n");
                             inputInvalid = false;
                        else
                             try
                                  numberOfThreads = Integer.parseInt(tempInput);
                                  if (numberOfThreads >= 0)
                                       inputInvalid = false;
                                  else
                                       System.out.println(
                                            "You entered a negative value for the number of threads. Try again.");
                             catch (NumberFormatException nfe)
                                  System.out.println(
                                       "You entered an invalid value for the number of threads. Try again.");
                   * Input focused access option.
                   inputInvalid = true;
                   while (inputInvalid)
                        System.out.print(
                             "Focused access? Determines whether each thread access the same element or a random element (y/n or blank for default): ");
                        String tempFocusedAccess = in.readLine();
                        if (tempFocusedAccess.equals("y"))
                             focusedAccess = true;
                             inputInvalid = false;
                        else if (tempFocusedAccess.equals("n"))
                             focusedAccess = false;
                             inputInvalid = false;
                        else if (tempFocusedAccess.equals(""))
                             System.out.println("default value used.\n");
                             inputInvalid = false;
                        else
                             System.out.println(
                                  "You entered an invalid input for focused access. Try again.");
                   * Input number of accesses.
                   inputInvalid = true;
                   while (inputInvalid)
                        System.out.print(
                             "Enter a non-negative value for the number of accesses each thread will complete: ");
                        tempInput = in.readLine();
                        if (tempInput.equals(""))
                             System.out.println("default value used.\n");
                             inputInvalid = false;
                        else
                             try
                                  numberOfAccesses = Integer.parseInt(tempInput);
                                  if (numberOfAccesses >= 0)
                                       inputInvalid = false;
                                  else
                                       System.out.println(
                                            "You entered a negative value for the number of accesses per thread. Try again.");
                             catch (NumberFormatException nfe)
                                  System.out.println(
                                       "You entered an invalid value for the number of accesses per thread. Try again.");
                   * Input start offset.
                   inputInvalid = true;
                   while (inputInvalid)
                        System.out.print("Enter the start offset: ");
                        tempInput = in.readLine();
                        if (tempInput.equals(""))
                             System.out.println("default value used.\n");
                             inputInvalid = false;
                        else
                             try
                                  startOffset = Integer.parseInt(tempInput);
                                  if (startOffset <= numberOfAccesses
                                       && startOffset >= 0)
                                       inputInvalid = false;
                                  else
                                       System.out.println(
                                            "You entered an invalid input for start offset. Try again.");
                             catch (NumberFormatException nfe)
                                  System.out.println(
                                       "You entered an invalid value for the start offset. Try again.");
                   * Input end offset.
                   inputInvalid = true;
                   while (inputInvalid)
                        System.out.print("Enter the end offset: ");
                        tempInput = in.readLine();
                        if (tempInput.equals(""))
                             System.out.println("default value used.\n");
                             inputInvalid = false;
                        else
                             try
                                  endOffset = Integer.parseInt(tempInput);
                                  if (endOffset <= numberOfAccesses && endOffset >= 0)
                                       inputInvalid = false;
                                  else
                                       System.out.println(
                                            "You entered an invalid input for end offset. Try again.");
                             catch (NumberFormatException nfe)
                                  System.out.println(
                                       "You entered an invalid value for the end offset. Try again.");
                   * Create a Hashtable, or a Hashmap?
                   inputInvalid = true;
                   while (inputInvalid)
                        System.out.print(
                             "Use HashMap or HashTable (enter m for HashMap, t for HashTable)? ");
                        String tempMapTable = in.readLine();
                        if (tempMapTable.equals("m"))
                             mapOrTable = true;
                             inputInvalid = false;
                        else if (tempMapTable.equals("t"))
                             mapOrTable = false;
                             inputInvalid = false;
                        else if (tempMapTable.equals(""))
                             System.out.println("default value used.\n");
                             inputInvalid = false;
                        else
                             System.out.println(
                                  "You entered an invalid input. Try again.");
              catch (IOException i)
                   System.out.println("IOException caught: " + i.getMessage());
              * End of obtaining input section. *****
              * Create a HashTable or HashMap of the size and distribution specified.
              Object hash;
              if (mapOrTable)
                   // create a HashMap
                   hash = new HashMap(numberOfElements);
              else
                   // create a HashTable
                   hash = new Hashtable(numberOfElements);
              char c[] = new char[sizeOfElement];
              for (int i = 0; i < numberOfElements; i++)
                   if (mapOrTable)
                        ((HashMap) hash).put(new Integer(i), new String(c));
                   else
                        ((Hashtable) hash).put(new Integer(i), new String(c));
              c = null; // Explicitly release c.
              * Create the specified number of threads.
              AccessorThread accessor[] = new AccessorThread[numberOfThreads];
              long seed;
              for (int i = 0; i < numberOfThreads; i++)
                   // Have a different seed for creating random number for each thread.
                   seed = System.currentTimeMillis() + 77 * i;
                   accessor[i] =
                        new AccessorThread(
                             hash,
                             numberOfElements,
                             focusedAccess,
                             numberOfAccesses,
                             startOffset,
                             endOffset,
                             seed);
                   // Start the thread.
                   accessor.start();
              * Make main wait for all threads to die before continuing.
              try
                   for (int i = 0; i < numberOfThreads; i++)
                        accessor[i].join();
              catch (InterruptedException ie)
                   System.out.println(
                        "InterruptedException caught: " + ie.getMessage());
              * Threads have now been run, so create a statistical report.
              System.out.println(
                   "The following settings were used for this test: \n"
                        + "Number of elements: "
                        + numberOfElements
                        + "\n"
                        + "Size of elements: "
                        + sizeOfElement
                        + "\n"
                        + "Number of threads: "
                        + numberOfThreads
                        + "\n"
                        + "Focused access: "
                        + focusedAccess
                        + "\n"
                        + "Number of accesses: "
                        + numberOfAccesses
                        + "\n"
                        + "Start offset: "
                        + startOffset
                        + "\n"
                        + "End offset: "
                        + endOffset);
              System.out.print("HashMap or HashTable: ");
              if (mapOrTable)
                   System.out.println("HashMap.\n");
              else
                   System.out.println("HashTable.\n");
              System.out.println("Statistic report: ");
              long avgTime;
              long avgTotalTime = 0;
              for (int i = 1; i <= numberOfThreads; i++)
                   avgTotalTime += accessor[i - 1].getAccessTime();
                   avgTime = accessor[i - 1].getAccessTime() / numberOfAccesses;
                   System.out.println(
                        "Thread "
                             + i
                             + "... "
                             + accessor[i
                             - 1].getStatus()
                             + " Total access time: "
                             + accessor[i
                             - 1].getAccessTime()
                             + " ms. Avg individual access time: "
                             + avgTime
                             + " ms.");
              avgTotalTime = avgTotalTime / numberOfThreads;
              // Make it an average over all threads.
              System.out.println(
                   "\nThe average total access time over all threads: "
                        + avgTotalTime
                        + " ms.");
    File#2: AccessorThread.java
    import java.util.Hashtable;
    import java.util.HashMap;
    import java.util.Random;
    * Created on May 13, 2003
    * @author llai
    * Threaded class that accesses a hashtable a certain number of times
    * and measures the access time for a certain number of accesses.
    public class AccessorThread extends Thread
         private Object hash;
         private int numberOfElements;
         private boolean focusedAccess;
         private int numberOfAccesses;
         private int startOffset;
         private int endOffset;
         private long seed;
         private long totalAccessTime;
         private String status;
         * Constructor
         * @param h the Hashtable or HashMap
         * @param keyToAccess the key to access for this thread
         * @param numberOfAccesses the number of access times
         * @param startOffset the start offset
         * @param endOffset the end offset
         public AccessorThread(
              Object h,
              int numberOfElements,
              boolean focusedAccess,
              int numberOfAccesses,
              int startOffset,
              int endOffset,
              long seed)
              this.hash = h;
              this.numberOfElements = numberOfElements;
              this.focusedAccess = focusedAccess;
              this.numberOfAccesses = numberOfAccesses;
              this.startOffset = startOffset;
              this.endOffset = endOffset;
              this.seed = seed;
              status = "Status: alive.";
         * @return the total access time.
         public long getAccessTime()
              return totalAccessTime;
         * @return the status of the thread.
         public String getStatus()
              return status;
         * @return the seed.
         public long getSeed()
              return seed;
         * Run method, accesses the hashtable at keyToAccess for
         * numberOfAccesses times, and measures the response time for
         * a certain number of those accesses.
         public void run()
              * Begin accessing the table, time only after startOffset accesses,
              * and only up to (numberOfAccesses - endOffset) accesses.
              * Access one value if focusedAccess on.
              * Access random values if focusedAccess off.
              Random numGenerator = new Random(seed);
              if (focusedAccess)
                   Object keyToAccess =
                        new Integer(numGenerator.nextInt(numberOfElements));
                   // Access without timing for the first startOffset accesses.
                   int i;
                   // Check if hash is a HashMap or Hashtable.
                   if (hash instanceof HashMap)
                        for (i = 0; i < startOffset; i++)
                             ((HashMap) hash).get(keyToAccess);
                        // Now start timing for the accesses.
                        long startTime = System.currentTimeMillis();
                        while (i < numberOfAccesses - endOffset)
                             ((HashMap) hash).get(keyToAccess);
                             i++;
                        long stopTime = System.currentTimeMillis();
                        totalAccessTime = stopTime - startTime;
                        // Finish accessing the remainder of endOffset times if endOffset is not >= (numberOfAccesses - startOffset).
                        while (i < numberOfAccesses)
                             ((HashMap) hash).get(keyToAccess);
                             i++;
                   else if (hash instanceof Hashtable)
                        for (i = 0; i < startOffset; i++)
                             ((Hashtable) hash).get(keyToAccess);
                        // Now start timing for the accesses.
                        long startTime = System.currentTimeMillis();
                        while (i < numberOfAccesses - endOffset)
                             ((Hashtable) hash).get(keyToAccess);
                             i++;
                        long stopTime = System.currentTimeMillis();
                        totalAccessTime = stopTime - startTime;
                        // Finish accessing the remainder of endOffset times if endOffset is not >= (numberOfAccesses - startOffset).
                        while (i < numberOfAccesses)
                             ((Hashtable) hash).get(keyToAccess);
                             i++;
              // Or else !focusedAccess, therefore access random values.
              else
                   * Get random keys to access and store in an array of Integer objects.
                   * Limit the array to 1000 integer objects.
                   int numberOfRandomInts = numberOfAccesses;
                   if (numberOfAccesses > 1000)
                        numberOfRandomInts = 1000;
                   Integer keysToAccess[] = new Integer[numberOfRandomInts];
                   for (int q = 0; q < numberOfRandomInts; q++)
                        keysToAccess[q] =
                             new Integer(numGenerator.nextInt(numberOfElements));
                   int i;
                   if (hash instanceof HashMap)
                        for (i = 0; i < startOffset; i++)
                             ((HashMap) hash).get(keysToAccess[i % numberOfRandomInts]);
                        // Now start timing for the accesses.
                        long startTime = System.currentTimeMillis();
                        while (i < numberOfAccesses - endOffset)
                             ((HashMap) hash).get(keysToAccess[i % numberOfRandomInts]);
                             i++;
                        // Stop the timing.
                        long stopTime = System.currentTimeMillis();
                        totalAccessTime = stopTime - startTime;
                        // Finish accessing the remainder of endOffset times if endOffset is not >= (numberOfAccesses - startOffset).
                        while (i < numberOfAccesses)
                             ((HashMap) hash).get(keysToAccess[i % numberOfRandomInts]);
                             i++;
                   else if (hash instanceof Hashtable)
                        for (i = 0; i < startOffset; i++)
                             ((Hashtable) hash).get(keysToAccess[i % numberOfRandomInts]);
                        // Now start timing for the accesses.
                        long startTime = System.currentTimeMillis();
                        while (i < numberOfAccesses - endOffset)
                             ((Hashtable) hash).get(keysToAccess[i % numberOfRandomInts]);
                             i++;
                        // Stop the timing.
                        long stopTime = System.currentTimeMillis();
                        totalAccessTime = stopTime - startTime;
                        // Finish accessing the remainder of endOffset times if endOffset is not >= (numberOfAccesses - startOffset).
                        while (i < numberOfAccesses)
                             ((Hashtable) hash).get(keysToAccess[i % numberOfRandomInts]);
                             i++;
              status = "Status: dead.";
    # File #3: run.sh
    echo Compiling the program...
    javac Driver.java AccessorThread.java
    export CLASSPATH=.
    echo Running the program...
    java Driver

  • Terminating enqueued threads at synchronized block

    Hi!
    I would really appreciate your opinions: :)
    The application desing:
    - I'm developing a web applicaction running on a Tomcat server.
    - The app is being developed using Struts and Spring.
    - Pages (presentation layer) are made of JSPs.
    - There are Spring beans (Services) that execute the business logic.
    - These Services are used by the Struts Actions.
    My problem case:
    1. When you submit myPage.jsp, MyAction.java's execute method is called.
    2. MyAction.java uses MyService.java's "process()" method to do some file processing that takes 2 to 3 hours to finish.
    3. This MyService.java is a singleton Spring bean.
    4. The call to process() method is synchronized on MyAction.java like this:
    public ActionForward execute(...) throws Exception {
         // Some code ...
         synchronized (this) {
              myService.process(...); // This method takes up to 3 hours to return
              // Some code ...
         return mapping.findForward("success");
    }As you can imagine, many requests (threads) will be enqueued at the synchronized keyword line. Because of this, I need to provide a cancelation functionality. This would be fired by a cancel button on myPage.jsp.
    So, if you tried to launch the so-long-process by the "Process" button on myPage.jsp and you received a "Waiting..." message at your screen (because the 3 hours process was launched by another client), you should be able to cancel your processing request (because you don't want to wait so much time to begin your file processing).
    I would really appreciate your opinions on which would be the best approach to achive this cancelation functionality.
    I'm sure there's a better way than the one I came up with: I could populate a class variable Map with "sessionId - Thread" (key - value) everytime a request arrives at the line before the synchronized block. Thus, when you clicked the Cancel button, MyAction.java would get the request's session id and then get the Thread it must terminate from the Map. Having the Thread instance, I could maybe call it's interrupt method.
    I don't think that's the best approach, but it's the only one I could thought about.
    Thank you very much for your time and opinions!

    Well, first thing I'd say is that if you use Spring, you'd be better off using it's own Controller architecture which is, to my mind, a lot more developed than Struts, especially now you can do pretty much the whole thing with @RequestMapping rather than XML.
    Having a web transaction wait for a long running server action is basically a bad idea. Rather you should have the web front end launch the file processing job and return immediately, probably showing a list of jobs to the user which may be queued, running or finished (for good or ill). One technique is to display a "background action in progress" page which submits a new transaction every few minutes to check if the job has finished yet (using a Javascript timer). If the job is still queued or running then this request displays the "in progress" page again, if finished it displays the result.
    Such a page could have a "Stop" button to abort the running job if feasible.
    I would suggest that you have a queue of background jobs, probably serviced by a ThreadPoolExecuter. The initial request simply builds a request object and queues it.
    Use a ContextListener object to create the queue and start the executer when the application starts, and close it down when the application is stopped,

  • Problems with synchronizing iCal with iCloud accounts on my Mac Pro

    I have problems with synchronizing iCal with iCloud calender accounts on my Mac Pro runnning OS 10.6.8
    (error message "HTTP/1.1 403 Forbidden" på handlingen CalDAVAccountRefreshQueueableOperation.)
    It works fine on iOS devices.

    Due to lacking hardware driver compatibility i our graphic production environment we can't upgrade to Lion.
    Does that mean that it after the closing of MobileMe is impossible to synchronize calenders to Mac's running OS 10.6.8 ??

  • Hi All,problem in synchronizing toughbook

    Hi All,
             Pls provide the solution for the problem  when synchronizing toughbook  .Its Urgent .

    'Hi Bharat,
    well, can you connect to the NWA from the Toughbook? It could be that you have some settings on the Toughbook that avoid this.
    First test: Connect via Ethernet in the internal Network. Then try to sync - is this working? Is the setting correct?
    If this is ok, then check via GPRS - first to call the Webservers J2EE Main page, then the NWA and finally try to sync.
    The problem: it has nothing to do with the Hardware as such I think - even a Toughbook is a normal Laptop. The problem seems to be in the Landscape. Your URL setting is not correct or there is a Firewall in between blocking the access to the Server - or you have not setup the Toughbook to alllow TCP/IP calls at all.
    So this is the area you need to look at.
    Hope this helps to give you a hint where to look at to solve the issue!
    Regards,
    Oliver

  • Using String or Integer for synchronized blocks

    Hi,
    I have seen in the past the usage of structures like the following:
    class MyClass {
      private static final String lockObject =  "XX";
      void mySyncFunction() {
        // do unsynchronized stuff
        synchronized( lockObject ) {
           // do synchronized stuff
        // do more unsynchronized stuff
    }This code works, but I am unsure about using a String (or an Integer for that matter) instead of Object lockObject = new Object().
    My guess is that if two different classes where to use the same String, for instance "XX" as above, that would mean trouble for the synchronized blocks. Is there any other argument I can use against this practice?

    You can do this:
    private static final String lockObject = new String("XX");You can guarantee more safety this way above. But anyway, not that it is bad, but is there any special reason for using a String or a Integer? Why not a simple Object for that synchronization?

  • 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.

  • Time synchronization poorness caused to block connection

    Dear Microsotf,
    I have VDS windows 2008r2 + Sql Server 2008 Express Ed. I am running MuOnline Private server (online gaming). But my OS system time is delaying (7 Secounds Delaying every 15 minutes) Time is cyritical for online games. problem
    was defined after lots of tests as a processor clock problem... which was time-running slower than expected to do (about -1 minute for every regular hour, checked with atomic clock)... and that for MultiPlayer games is crucial. 
    In the Gameserver.exe i got that log .;
    Time synchronization poorness caused to block connection -7828
    WSARecv() failed with error 10038
    What will the solution?

    Simply use a public NTP server for time sync.
    You can refer to that to how to configure time sync on your server: https://pubs.vmware.com/vsphere-51/index.jsp?topic=%2Fcom.vmware.vsphere.security.doc%2FGUID-B77341E3-9D7D-48B6-A221-B782C21AF98E.html
    This posting is provided AS IS with no warranties or guarantees , and confers no rights.
    Ahmed MALEK
    My Website Link
    My Linkedin Profile
    My MVP Profile

  • Java thread synchronized block

    i am still a noob comes to thread and synchronized.
    i heard people said that i shouldn't synchronized on "mySet" because "mySet" is getting modified in the synchronized block.
    is this true?
    or should i use a different object to synchronized the block. what's the advantage or disadvantage to use a different object to synchronized the block.
    thanks
    public class Test {
      final Set mySet = new HashSet(); 
      final Map myMap = new HashMap();
      public void add(Object o) {
        synchronize(mySet) {
          mySet.add(o);
          myMap.add(o);
      public void clear(){
        synchronize(mySet) {
          mySet.clear();
          myMap.clear();
    }

    yaliu07 wrote:
    i am still a noob comes to thread and synchronized.
    i heard people said that i shouldn't synchronized on "mySet" because "mySet" is getting modified in the synchronized block.
    is this true? No, that's not a reason not to sync on that object. In fact, in some cases it's a reason why you should sync on that object.
    Most of the time it doesn't matter which object you sync on, as long as all the relevant blocks are synced on the same object. There are a couple of considerations to keep in mind though that might affect the choice of object.
    In some cases, you want to sync on an object that's not exposed to the outside world, for instance a private Object member variable that exists only to be a lock. The reason for this is that if you sync on something that's exposed to the outside (such as "this", which is what gets synced on when you declare a non-static method as synchronized), then other code might also sync on that object, causing deadlock or thread starvation.
    In other cases, you DO want to expose the object, so that you can use it to ensure that other code and your synced code only enter the critical sections one thread at a time. For instance, in Collections.synchronizedXxx() methods, the return object's methods are all synced on "this", and any code that iterates over that collection must also sync on that object, so that the iteration code and the collection object's own code don't step on each other's toes.
    Much of the time, however, the choice of an object to sync on is just one that's convenient and logical for the humans writing and reading the code.

Maybe you are looking for

  • How to covert before and after image details from logdump to SQL

    Hi, Through logdump,i am able to retrieve below before and after image details for an update statement. Instead of below ascii format output, i need to know the complete sql statement before update and after update. Is there any command to covert bel

  • Why does my live site have formatting errors?

    I have uploaded my site, made changes, re-uploaded, and then did that several times.  Now, all of a sudden, the appearance of my fonts when I publish the amended site looks different than it does on iWeb - and not in a good way.  How can I fix these

  • Error in displaying date time value in Thai Windows OS browser.

    Hi, I have a problem displaying date time in the browser which is installed with Thai Windows OS. The time portion (the subset of datetime) does seemed to show correctly. Initially i am suspecting the virtual machine problem but i tried on bith java

  • Deploying .ear files

    How can I deploy an .ear file if I want to use another Web Server(like iPlanet) to handle static content?? Do I have to separate .html, .gif, etc from .jsp files?? If this is true, .ear files are useful only in developing mode. Thanks, Austre

  • External Routines

    I try make the external routine writen in C. Function writen in C and stored in D:\extproc\zzz1.dll I make the library and function CREATE or replace LIBRARY externProcedures AS 'D:\extproc\zzz1.dll' create or replace function pls_max(x binary_intege