which will cause 'notify() and wait()' mechanism no longer works?

Hi all

My application has worked for a few years, unless the user recently upgraded to OS7.1 and to try out my new device, all of a sudden, he is part works not properly.

Appplcaition will download data from the server, long story Short,

When there is no queue of download, application will wait until asked to download real.

my code something like the follow up:

        InvokeContainer c = new InvokeContainer(r);
        synchronized (c.syncObj) {
            // push to queue
            synchronized (_queue) { _queue.addElement(c); }
            LogManager.getInstance().add("Notify queue Thread _queue size " + _queue.size());
            synchronized (_queueSyncObj) { _queueSyncObj.notifyAll(); }
            // wait for release
           // LogManager.getInstance().add("Invoke data wait to release");
            //synchronized(c.syncObj){
                try { c.syncObj.wait(); } catch (Exception ex) {}
            //}
            LogManager.getInstance().add("Invoke data released");
        }
        while (!_stop) {
            InvokeContainer c = null;

            // wait for invoke
            c = getNextInvoke();
            if (c == null) {
                LogManager.getInstance().add("Wait For next queue");
                synchronized (_queueSyncObj) {
                    try {
                        _queueSyncObj.wait();
                        LogManager.getInstance().add("Invoked");
                    } catch (Exception ex) {
                        LogManager.getInstance().add("Exception happened: " + ex.toString());
                    }
                }
                c = getNextInvoke();
                LogManager.getInstance().add("Get a new queue ");
            }

My question is:

my request always stop at the:

 LogManager.getInstance().add("Notify queue Thread _queue size " + _queue.size());

and I saw there's a queue, waiting, however, the line after wait() never called.

which will cause notify() citing not wait()?

For me, in places, your code seems too complicated for what he seeks to achieve.  I'll try to simplify.

First you have loads of protection around your creating a Singleton RuntimeStore object.  This seems pointless.  Take a look at this:

http://supportforums.BlackBerry.com/T5/Java-development/create-a-singleton-using-the-RuntimeStore/TA...

Go through your code, I wonder what follows:

(1) public static synchronized IPCThread getServerInstance() {}

Why is this it is synchronized?  Iron several people getting to this offers no additional protection.

(2) synchronized (GlobalSync.getSyncObj (GUID))...

This synchronized block offers no additional protection either.  Either the

IPCThread will be there or it won't, there is no possibility of a race condition causes you a problem here.

(3) public static synchronized IPCThread initServerInstance() {}
synchronized (GlobalSync.getSyncObj (GUID)) {}

Here, there might be some value to have only one person to create it at the same time.  But if it's a question, then the second person through should check if it has been created, this code is not.  Thus, each invocation of

initServerInstance()

will create and start a new IPCThread.  The synchronized are totally redundant and you have a potential hole in your treatment.

(4) public synchronized static getInstance() {} IPCThread

you have another way to get an IPCThread, which in fact is not identical to the above and, will be different if you start another instance of your Application, for example an alternative entry or a variant of starting.

I recommend that you replace it with the unique getInstance() method based on article.  Do start the IPCThread if it creates.

OK, I understand that you don't think that this is related to your problem, but with the code you have, there may be several IPCThreads and would not help.

Now on your invocation code.

Can you please remove static from the following:

private static class InvokeContainer...

As far as I KNOW, he does not buy you anything in this circumstance, and it confuses me.

The idea here seems to be that you can provide an executable in this process, which it runs and then inform the task (if necessary) awaiting.  You pack the floor area in an InvokeContainer.

The first thing to look at, it's how you entered extracting from the queue.  Here you protect with this line:

synchronized (inasmuch)

So what you're saying to me here, it's that you will protect this treatment in protecting access to the inasmuch.  Something we will add it to the queue. or something is going to take off it the queue, both may not occur at the same time.  That's ok.

So how do add you to the queue?

Ignoring the code that will process if the process id is the same, we get this:

InvokeContainer c = new InvokeContainer (r);
synchronized (c.syncObj) {}
Push the queue
synchronized (inasmuch) {_queue.addElement (c) ;}
synchronized (_queueSyncObj) {_queueSyncObj.notifyAll () ;}
wait for the release
try {c.syncObj.wait () ;} catch (Exception ex) {}}
}

Now, we have already seen the queue is protected using "synchronized (inasmuch).  But this code will not prevent the entry we just added picked up before that we treat the notify - in other words, the notification cannot be taken into account.  But that's OK.  The reverse is not.  If the Thread that processes the code IPCThread is at this point:

If (c == null) {}

and the Thread that the addition of the transformation executes these two instructions:

synchronized (inasmuch) {_queue.addElement (c) ;}
synchronized (_queueSyncObj) {_queueSyncObj.notifyAll () ;}

then the IPCThread will miss warn him.

To fix this, I'll do what I suggested earlier.

The way, this seems very strange:

InvokeContainer c = new InvokeContainer (r);
synchronized (c.syncObj) {...}

but in fact, this means that the code will never fail of the treated IPCThread this practicable, since the notification

synchronized (c.syncObj) {c.syncObj.notify () ;}

Cannot run until this thread is waiting.  It's a good thing.

So that leaves only one thing to discuss - the.invokeAsync.  This code looks good, if the

synchronized (c.syncObj) {...}

is completely redundant.

Summary - 2 recommendations:

(a) change your Singleton IPCThread to use the RuntimeStore method suggested in the KB article

(b) check the inside of the protection of

synchronized (_queueSyncObj) {}

which

c = getNextInvoke();

is always set to null.

Finally, have you thought about putting a delay time in your expectations, while without worrying about the activity or not, the Thread will pick up every now and again work?  For example:

_queueSyncObj.wait (1000);

Edit: Minor typo and readability...

Tags: BlackBerry Developers

Similar Questions

  • I have a personal account of CC.  I'll get a CC account through my work for my machine here soon.  In the meantime, I can run my CC on my work computer or which will cause problems in the future?

    I have a personal account of CC.  I'll get a CC account through my work for my machine here soon.  In the meantime, I can run my CC on my work computer or which will cause problems in the future?

    When you install the cloud on a computer, the use of the programs is related to the Adobe ID used for installation

    Then use the cloud with a different ID, you need to disconnect from your personal account and sign in to your professional account to install and use

    If you would eventually use only the ID of your work on your work computer, it would probably be best to completely remove your personal ID and Cloud programs before you install using your work ID.

    Sign out of your personal account... Uninstall... to run vacuuming...

    -http://helpx.adobe.com/creative-cloud/help/install-apps.html (and uninstall)

    -using the vacuuming after uninstalling and prior to the relocation is necessary

    -https://helpx.adobe.com/creative-suite/kb/cs5-cleaner-tool-installation-problems.html

    -Restart your computer... Log in to your account... Install

  • Is there a version of edge hosted or provided the new Adobe host which will be available without the cloud that I work in an environment without the interent?

    Is there a version of edge hosted or provided the new Adobe host which will be available without the cloud that I work in an environment without internet?

    Not as far as I can tell, but with a subscription of cloud you can always download Edge animate when you have a connection available and later use it without connection.

  • left and right arrows no longer work in Safari, work in Excel, the top and bottom do not work

    left and right arrows no longer work in Safari, work in Excel, arrows up and down to work in Safari.  Any suggestions?

    What you're trying to do with the left and right arrows in Safari? The only time they will do anything is:

    • in a text edit box
    • If the page has a horizontal scroll bar
    • If the page is zoomed
  • Safari crashes in el capitan, search bar and tabs are no longer works

    Safari crashes in el capitan, search bar and tabs are no longer works. Happening right after the update - I installed another browser, Opera. That works, but I need to Safari anyway, so what to do?

    OS X EL CAPITAN, 10.11.3 Version

    Try the following steps:

    A possible solution to the problem of address bar: disable the Safari Suggestions

    If you have problems to open Web pages, take a look at these techniques proposed by Apple of troubleshooting.

    https://support.Apple.com/en-us/HT204098

    Go to the Safari menu (at the top right of your screen next to the Apple icon), choose 'Quit Safari'

    Press the "Shift" key and while holding this button on your unique keyboard, click the icon of Safari on your Dock.

    Open Safari - Preferences - Privacy - data to remove any Web site.

    Open the menu to go with the Option (Alt) key - library - key locate Safari folder and place it on your desktop. Restart your Mac, open Safari and delete the file from your desktop.

    Also, try the following steps:

    Restart your Mac.

    Try to start:

    -Stop your Mac

    -Wait until your computer turns off and after that press the power button

    -Just after you hear the startup tone, press in and hold the SHIFT key

    -Release the SHIFT key when you see a gray Apple sign and the progress under this sign bar

    -Once your Mac boot, restart dhcpd as you usually do.

  • I have CS5 with two computers under license, and a pc no longer works. How can I put CS5 on my new laptop with a valid license?

    I have CS5 with two computers under license, and a pc no longer works. How can I put CS5 on my new laptop with a valid license?

    You will need to contact Adobe to reset your license.

  • The keyboard and the mouse no longer works to update you Sierra

    Hello, I upgraded to OS Sierra and I began to spend more and suspending Notepad, then I do not recognize their keyboard and mouse notbook. It forces the walk outside and then worked, but after a few days I don't work any more.

    Thank you

    The keyboard and the mouse no longer works to update you Sierra

    Hi gnardone,

    Thanks for posting in the Community Support from Apple. I understand that you are having problems using your mouse and your keyboard after the update for Sierra. View the work of keyboard and mouse are crucial for your Mac, so I can understand how this is a problem for you. I'm happy to offer assistance.

    You are having problems with the keyboard and the trackpad that are part of your MacBook or you are having problems with a keyboard and an external mouse? I recommend taking a look at the article below.

    If your Apple wireless mouse, keyboard or trackpad doesn't work as expected

    If you're still having trouble, let us know what kind of mouse and keyboard that you are having problems with and what you have tried to solve this problem.

    Best regards.

  • Replace old hard drive with an SSD.  Nowsome keys on the keyboard no longer works.  Ex 'e' and 'b' keys no longer work?  Any idea what could take place in the disc replacement?

    Replace old hard drive with an SSD.  Now some of the keys on the keyboard stopped working.  Ex 'e' and 'b' keys no longer work?  Any idea what could take place in the disc replacement?

    Probably nothing, it's probably a fluke. Try resetting the SMC and the PRAM by iMac Intel SCM and reset the PRAM. If this does not work, try a USB keyboard to test, if it works then your original keyboard has failed and must be replaced.

  • Satellite A200 - 19K: double keyboard lights up and the mouse no longer works

    Hello

    I just brought a notebook a200 19 k and the double keyboard lights up and the mouse no longer works.
    I can't find why it does this in the manual and what is the purpose of light with symbols on it.

    The symbols have a purpose. Thank you very much

    Hello

    As far as I know that not all mobile A200 were shipped with this function called TouchPad/Dual Mode Pad touchpad

    The dual-mode tablet buttons provide many different functions such as:

    1.) button to -> it toggle cursor mode and the mode button.
    When you switch the button mode button flashes blue and the mouse does not work

    (2.)-> volume button increases or decreases the volume of the speakers and headphones

    (3.)-> e-mail button starts you mailbox to receive and send emails

    4.) button ConfigFree -> starts the ConfigFree tool

    5.)-> Windows Vista Photo Gallery button starts the Windows Vista Photo Gallery

    The other three buttons to the bottom of the trim can be configured with different functions.

    Please refer to the properties for pad synaptic dual for more details!

  • I updated my operating system Mac Mountain Lion and my CS2 no longer works. Is there a solution?

    I updated my operating system Mac Mountain Lion and my CS2 no longer works. Is there a solution? CS2 works great for my purpose.

    Unfortunately it is the control of Adobe on the outside. Recent versions of Mac OS x simply do not contain the necessary components to the system more. Short of signing up for creative cloud / purchase CS6, there is no way to fix it, though, if "CS2 works just fine" for you, PS Elements could suffice just as well these days, given that all of the features is similar to your old version of PS...

    Mylenium

  • Automatic updates which will install never and will never disappear.

    Automatic updates of Windows shows me this 'important ': update

    A security update for .NET Framework 4 on Windows XP, Windows Server 2003, Windows Vista, Windows 7, Windows Server 2008, Windows Server 2008 R2 for x 64 systems (KB2160841)

    I had windows install this update about 7 times but the automatic updates says that I need to install it.  Why is - this will not install and stop to remember?

    You posted in the wrong section. Please repost to section updates from Windows:
    http://social.answers.Microsoft.com/forums/en-us/vistawu/threads

    The section has combined XP, Vista and Win7, in case you're wondering. For the benefits of others looking for answers, please mark as answer suggestion if it solves your problem.

  • I turned on this morning with my imac and my password no longer works.  What is happening with this?

    The only change that I made using my imac was change my email address on different sites, such as Apple, but using a different computer.  I have no connection issues in my icloud & apple accounts, but the imac allows me to do more.

    Any ideas?  Thank you.

    Password reset

    1. turn off the computer and wait a few minutes.

    2. turn the & at the same time hold down the 'command' & keys 'R '.

    3. next screen... In the menu bar, click on utilities (NOT OS X UTILITIES)

    4. in the drop down menu, click Terminal.

    5. in the small terminal window: Type-> resetpassword Hit return key.

    6 reset password window will appear.  Follow the on-screen instructions to reset the password.  Make sure you only select the administrator account to reset the password.

    Also, check out the following user Tip: reset the user password in OS X Lion, Mountain Lion, Mavericks and Yosemite

    Knowledge Base articles: change or reset a user account on your Mac password and this article what to do if your Mac refuses to accept your password.

  • Links to open or download new items (PDF format) attachments in gmail and Web pages no longer work. Suddenly started happening last week.

    When I click on the links to open documents etc from within a Web page or as attachments in gmail, nothing happens. The browser window shows it is going somewhere / do something, but then nothing happens. Please help quickly resolve because it almost judge firefox unusable.

    Thank you
    Robert

    Hello

    Try Firefox Safe mode to see if the problem goes away. Firefox Safe mode is a troubleshooting mode that temporarily disables hardware acceleration, restores some settings and disables add-ons (extensions and themes).

    If Firefox is open, you can restart Firefox Safe mode in the Help menu:

    • Click the menu button

      click Help

      then select restart with disabled modules.

    If Firefox does not work, you can start Firefox in Mode safe as follows:

    • On Windows: Hold down the SHIFT key when you open the desktop Firefox or shortcut in the start menu.
    • On Mac: Hold the option key during the startup of Firefox.
    • On Linux: Exit Firefox, go to your Terminal and run firefox-safe-mode
      (you may need to specify the installation path of Firefox for example/usr/lib/firefox)

    When the Firefox Safe Mode window appears, select "start mode safe."

    If the problem is not present in Firefox Safe Mode, your problem is probably caused by an extension, theme or hardware acceleration. Please follow the steps described in the section Troubleshooting extensions, themes and problems of hardware acceleration to resolve common Firefox problems to find the cause.

    To exit safe mode of Firefox, simply close Firefox and wait a few seconds before you open Firefox for normal use again.

    When find you what is causing your problems, please let us know. This might help others with the same problem.

  • The top of the window disappeared. Cannot minimize and two monitors no longer work

    Hello! It's really stupid, but from what I understand, I must have pressed a shortcut to something because now the top of my window disappeared (you know, the part "minimize", "maximize" and "Close" buttons). I found an explanation in the face of the same problem with illustrator, and the guy has resolved:

    "In the Illustrator menu bar, click"Window", then"framework of Application". It seems that the unchecked option will leave the application 'attached' to your primary monitor. Audit, he will place the application in a window of 'free form' that you are free to move. »

    This article describes my problem and and provides a solution, but I can't seem to find the setting of "application framework" in first CC. Help, please! Strange how dual monitors no longer work, despite their work earlier today, so I assumed that my window is maximized touched it. Don't know what shortcut, I pressed. I tried to reset the workspace.

    Thank you!

    ALT + space, then "maximize" worked. Seen that option earlier, but only tried the option reduce...

    Monitors to work as it should.

    Thank you much for the help!

  • removal, paint and clone tools no longer work

    I have photoshop cs3 running on windows xp.  removal, paint and clone tools do not work on any layer.  (other tools don't work. susch as red eye removal).  the layers are not locked.  I used these tools on many many occasions.  they just stop working.   I tried: resetting the preferences of the tool to their values by default, restarted my computer, restarted photoshop.  I hope I can avoid having to re - install cs3.  any help/advice will be greatly appreciated.  Thank you, leonard.

    If you are usind a Wacom or other check the pen tablet is far frrom the Tablet when you use the mouse and vice versa.

    If the element is used is too narrow, it can interfere with the functions of the paint.

    Alternatively, you can confirm this by disconnecting the tablet to see if the problem goes away.

Maybe you are looking for

  • How can I find out what kind of RAM my Qosmio G30-161 has?

    I want to add more ram to my qosmio G30-161. I couldn't find any info on what type of ram or max ram that can be added to the manual. I read once but can't remember wherever it is max 4G with 2g of each... DDR2. I use windows media center as operatin

  • Impossible to remove the item from Windows Media Player

    Original title: Windows Media Player I downloaded some videos a few years ago and now I want to remove them from the PC and Windows Media Player. They seem to be linked to a web address for each video. When I remove them, they still appear an hour or

  • service pack Windows update-windows 7 KB976932

    kindly help getting erro. details of error code 8024200d when installing updates

  • Windows keep my text on its own!

    Greetings, fellow Forum help Microsoft. I need help because my computer keep delete my text in any program I use! It started yesterday when I just changed my Note of Evernote. All of a sudden, my text has started quickly remove auto line-by-line. Tha

  • 6.6 Lightroom cannot read Raw (Nef) files.

    Up to a few days, I was using portable window. I got a new Macbook Pro 13 "."I installed LR6 on my new Mac and the catalogue LR transfer above the window for mac laptop. My photos are in the external hard drive. Open the LR catalog and work on my alr