Synchronized problem - I have a real challenge!

Hi,
I have a real synchronized problem. Please see the code and the output below and tell me what is wrong. It seens that synchronized is not working properly.
---> CODE:
public synchronized void publish(LogRecord record) {
if (!isLoggable(record)) {
return;
System.out.println("AutoPushMemoryHandler in - buffer index: " + count +
" lgth " + buffer.length +
" ts " + System.currentTimeMillis() +
" trd " + Thread.currentThread().getName());
try {
buffer[count] = record;
catch (ArrayIndexOutOfBoundsException ex) {
System.out.println("AutoPushMemoryHandler ArrayIndexOutOfBoundsException - buffer index: " + count +
" lgth " + buffer.length +
" ts: " + System.currentTimeMillis() +
" trd " + Thread.currentThread().getName());
return;
count++;
if ((record.getLevel().intValue() >= pushLevel.intValue()) ||
(count == buffer.length)) {
// we don't want to lost any log, so it's time to push
push();
System.out.println("AutoPushMemoryHandler out - buffer index: " + count +
" lgth " + buffer.length +
" ts " + System.currentTimeMillis() +
" trd " + Thread.currentThread().getName());
public synchronized void push() {
for (int i = 0; i < count; i++) {
LogRecord record = buffer;
target.publish(record);
// empty the buffer.
System.out.println("AutoPushMemoryHandler - push() executed" +
" trd " + Thread.currentThread().getName());
count = 0;
---> OUTPUT:
AutoPushMemoryHandler in - buffer index: 998 lgth 1000 ts 1035858336618 trd RequestProcessor[10]
AutoPushMemoryHandler out - buffer index: 999 lgth 1000 ts 1035858336618 trd RequestProcessor[10]
AutoPushMemoryHandler in - buffer index: 999 lgth 1000 ts 1035858336618 trd RequestProcessor[10]
AutoPushMemoryHandler in - buffer index: 1000 lgth 1000 ts 1035858340039 trd RequestProcessor[12]
AutoPushMemoryHandler ArrayIndexOutOfBoundsException - buffer index: 1000 lgth 1000 ts: 1035858340040 trd RequestProcessor[12]
QUESTION:
How is possible the thread RequestProcessor[12] enter in the method publish() if the RequestProcessor[10] did not leave the meyhod yet????? Note that publish() is synchronized!!!

You probably have several object instances, from looking at the code it calls target.push or target.publish. Synchronized only blocks other instances of the same object from concurrently executing synchronized code. If you truly need to lock the CLASS, not the INSTANCE of class, then you need to synchronize on another object, such as {YourClass}.class

Similar Messages

  • Just joined bt and have a real big problem!!!!

    hello there i was very happy untill this morning with my new bt infinity package which was installed last tuesday.i have only just realised with horror that i have taken delivery of the wrong tv box.we have chosen a humax youview box when we should have opted for a bt vision+ box so we could receive the extra 18 channels and sport.we ordered over the phone and i was told it was just a matter of paying a £10 fee to get espn and i didnt realise the extra channels i was paying an additional £12.50 for was the six packs add on which is completely different.anyway i rang up this morning and was told it would cost £199 to change boxes!!!!!!.is this correct??.if so ive got a year with a useless box with next to nothing i want to watch!!.what are my options please.
    on the plus side i am delighted with the phone and broadband!!

    jezstatham
    Visitor
    Posts: 3
    Registered: ‎14-04-2013
    Re: just joined bt and have a real big problem!!!!
    on ‎14-04-2013 22h57
    stuart can you give me a bit more info about the schedule for the humax box being enabled?
    It is scheduled for the summer but lime all schedules it could slip. It requires an update to the software
    They are currently working on delivering this service to those who have the existing boxes ie the Black Vision Box. The two separate platforms will disappear in time with YouView being the future. Have you checked to see if your exchange is multicast enabled
    Life | 1967 Plus Radio | 1000 Classical Hits | Kafka's World
    Someone Solved Your Question?
    Please let other members know by clicking on ’Mark as Accepted Solution’
    Helpful Post?
    If a post has been helpful, say thanks by clicking the ratings star.

  • Have a real problem i just can't make a reservation and this is the only way to contact apple . It seams to keep going to the american site .

    have a real problem i just can't make a reservation and this is the only way to contact apple . It seams to keep going to the american site .

    Apple world-wide support numbers are found at: http://support.apple.com/kb/HE57
    If this is regarding your information line that says a stolen iPhone, Apple can do nothing to help you.  You must track the iPhone yourself using iCloud and must have turned on Settings > iCloud > Find My Phone before it was stolen.  If that was not done, there is no way to track the iPhone.
    Report the theft to the police and the cell service provider and ask if they can blacklist the iPhone so it cannot be used.  Change all passwords associated with acconts on the iPhone.

  • HT3775 I'm using version 10.7.5 OSX. I can't play or use the normal AVI recently. Some problem with (codecs version incompatible with OSX) Please give me some help. I'm in Vietnam and to have a real place to have stuffs from Apple is ****-

    I'm using version 10.7.5 OSX. I can't play or use the normal AVI recently. Some problem with (codecs version incompatible with OSX) Please give me some help. I'm in Vietnam and to have a real place to have stuffs from Apple is ****…

    I would recommend that you download and install the excellent and Free "VLCPlayer for Mac", which reads many more types of files for video than Quicktime Player:
                 http://vlc-media-player.en.softonic.com/mac

  • Hi...i have a real problem i keep getting in game when i want ot buy something ...ur purchase could not be for assistance contact itunes suppocompleted rt any help plzzzz????

    hi...i have a real problem i keep getting in game when i want ot buy something ...ur purchase could not be for assistance contact itunes suppocompleted rt any help plzzzz????

    Slow down, take a deep breath and start over. Use complete sentences so your thoughts are lucid.

  • Problem with DAQmx and Real Time PCI-7041/6040E.

    Problem with DAQmx and Real Time PCI-7041/6040E.
    I have a problem with the Real Time card PCI-7041/6040E, I think it is properly installed because my software run with the traditional NI-DAQ. When I try to use the new DAQmx to acquire one signal, Labview doesn't see any device for de DAQ card 6040E.
    Information, I work on Windows XP and LabView v7.0.0 (NIDAQ RT v7.0.0, NI-Serial RT v2.5.2, NI-VISA v3.0.1 and NI-Watchdog v2.0.0).
    Could Labview RT run with new DAQmx ?
    What can I do to use DAQmx with PCI-7041/6040E?
    Thanks for your help !

    Hello,
    I refer to your posts because i am using the PCI 7041/6040E card as
    well but without any success to make it work. The problem I have
    already described in the following thread:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=120198
    Would be nice if you had a look on it, maybe you can help me. BTW, the
    thread starts with a problem of someone else, the difficulties I
    encountered are to be found a little bit to the bottom of the thread's
    page.
    Thank you!
    Dirk Völlger
    Darmstadt
    Message Edited by ratschnowski on 07-28-2005 07:14 AM

  • Synchronized problem in JSP/Servlet, please help me.

    Hi, all
    I have many processes in one JSP page or Servlet program of my project.
    When many people visit at one time, then the project throws some SQL/DB Errors.
    I have updated it and test it many times, I think, that is a synchronized problem.
    At last I used ��synchronized (this){my JSP/Servlt SQL/DB processes}�� to synchronize
    The process. Then the errors removed.
    And now I think that too danger to use the ��synchronized (this){}�� to synchronized.
    If use it then some other problem may be growling on. Such as when one people need to use
    This service others must to wait, the process may be too slow! And when an exception throws
    from the SQL/DB or some other place, what I do? Need any advice from you.
    Sincerely
    Urey
    *** my JSP/Servlt Server is tomcat ***

    As Chuck points out, there isn't a new instance of the Servlet/JSP for each request - they are probably all calling the same instance so any state will be shared. If your Connection is stored as a member variable then you'll have problems with it already being in use if two people hit the page at the same time.
    Limited resources such as database connections should ideally be pooled anyway to ensure that you're not opening them all the time and that you can control how many are open across the entire application. Then you'd simply need to get a fresh connection out of the pool at the top of the page and make sure you put it back when you're done.
    Incidentally, although it might work, synchronizing the database access in the JSP would be a bad idea since you'd just create a queue of requests waiting to use the one Connection whereas you really need a number of Connections to deal with everyone simultaneously.
    If you need some example code for a simple JSP using a database connection pool (DataSource) just say.
    Hope this helps.

  • Hai friends...can any 1?A  REAL CHALLENGE..

    IF WE WANT TO FETCH DATA FROM 1..DATABASE TABLE..WE HAVE 1 LAKH RECORDS...ITS REFLECTS..THE PERFORMS..HOW CAN WE IMPROVE TH E PERFORAMNCE..?

    Hi Satish,
    Real Challenge??
    Any of the performance tuning documents on SAP addresses this question. Just search on SDN and you will find many ways.
    Regards
    Aneesh.

  • Does TM have any real functional advantages over other solutions?

    Hi All
    Looking at possible network backup solutions. Does TM have any real functional advantages over something like SuperDuper? I'm not really looking for an "archive" solution, which is I think how a lot of people perhaps incorrectly view TM, but just something that will allow me to easily recover from corrupt/crashed system - TM seems rather overkill and complex for that?
    Any advice/views appreciated...jeremy

    Jeremy Trask wrote:
    Hi All
    Looking at possible network backup solutions. Does TM have any real functional advantages over something like SuperDuper? I'm not really looking for an "archive" solution, which is I think how a lot of people perhaps incorrectly view TM, but just something that will allow me to easily recover from corrupt/crashed system - TM seems rather overkill and complex for that?
    Officially, TM does not work over a network, except via Time Capsule or to another Mac running Leopard on the same local network: http://support.apple.com/kb/HT1733
    Some of us are able to use a USB drive attached to an Airport Extreme, or a shared drive on a Mac running Leopard or Snow Leopard on the same local network. Some others are using various NAS devices that claim to be TM-compatible, but often with various difficulties.
    So if you're set on a network solution, your options with TM are limited.
    CarbonCopyCloner does not work to any network destination, and I don't think SD does, either.
    Other than that, TM has two main advantages over the "clones:"
    Being able to do hourly incremental backups of new and changed items very quickly, it gives you an excellent chance of recovering something that was changed or deleted in error, or that got corrupted. Most other apps, especially CCC and SD, if they're backing-up your entire system, in most cases just aren't practical to run more than once or twice a day.
    Second, since every TM backup is, in effect, a full one, you can restore your entire system to the exact state it was in at the time of any backup, even if it was a previous version of Leopard or Snow Leopard. Many folks have, for example, successfully and easily downgraded from SL back to Leopard when they found they had incompatible apps or other problems.

  • The problem I have since I upgraded to Mavericks version 10.9.1 The problem appears only with Mail not with other programs, not even with my browser. When I try to zoom the text of an e-mail I received or sent , I can no longer use the keys Command   to e

    the problem I have since I upgraded to Mavericks version 10.9.1
    The problem appears only with Mail not with other programs, not even with my browser.
    When I try to zoom the text of an e-mail I received or sent , I can no longer use the keys Command + to enlarge the text, although I can reduce it with Command -.
    As I have a problem with my eyes, This is a serious matter for me.
    When I write an e-mail, if I select text and press Command +, it just displaces the text to the right.
    Now, my husband has a USB keyboard. If he connects it to my computer, his regular Command + does not work either, but  he uses the extended keyboard, then it works. Unfortunately, he needs it for a musical application which does not work with a wireless keyboard.

    Firefox 3.6.4 and 3.6.6 use a process called, "plugin-container.exe" which was using up most of my CPU when I opened up multiple tabs that contained Adobe Flash files, and caused Firefox to lock up.
    My solution was to use Firefox 3.5.10 which you can get from the Mozilla website at [http://www.mozilla.com/en-US/firefox/all-older.html]
    I am using Adobe Flash 10.1.53.64 without any problem in this version of Firefox. Check the release notes, I believe it contains all the latest security fixes in "Firefox 3.6.4".
    Hopefully, they will fix Firefox 3.6 in the next version (e.g. Firefox 3.6.7), until then you should probably use "Firefox 3.5.10".

  • I have an early 2011 MacBook Pro which has been running slow for a while. After looking at responses to similar problems I have downloaded and run EtreCheck and will post the output. Please can someone help me with what it all means.Thanks in advance

    I have an early 2011 MacBook Pro which has been running slow for a while. After looking at responses to similar problems I have downloaded and run EtreCheck. Please can someone help me with what it all means.
    Thanks in advance.
    EtreCheck version: 1.9.15 (52)
    Report generated 19 September 2014 08:07:14 GMT+8
    Hardware Information: ?
      MacBook Pro (13-inch, Early 2011) (Verified)
      MacBook Pro - model: MacBookPro8,1
      1 2.3 GHz Intel Core i5 CPU: 2 cores
      4 GB RAM
    Video Information: ?
      Intel HD Graphics 3000 - VRAM: 384 MB
      Color LCD 1280 x 800
    System Software: ?
      OS X 10.9.4 (13E28) - Uptime: 0 days 0:4:29
    Disk Information: ?
      Hitachi HTS545032B9A302 disk0 : (320.07 GB)
      S.M.A.R.T. Status: Verified
      EFI (disk0s1) <not mounted>: 209.7 MB
      Macintosh HD (disk0s2) / [Startup]: 319.21 GB (147 GB free)
      Recovery HD (disk0s3) <not mounted>: 650 MB
      MATSHITADVD-R   UJ-898 
    USB Information: ?
      Apple Inc. FaceTime HD Camera (Built-in)
      Apple Inc. BRCM2070 Hub
      Apple Inc. Bluetooth USB Host Controller
      Apple Inc. Apple Internal Keyboard / Trackpad
      Apple Computer, Inc. IR Receiver
    Thunderbolt Information: ?
      Apple Inc. thunderbolt_bus
    Gatekeeper: ?
      Mac App Store and identified developers
    Kernel Extensions: ?
      [not loaded] com.seagate.driver.PowSecDriverCore (5.2.4 - SDK 10.4) Support
      [not loaded] com.seagate.driver.PowSecLeafDriver_10_4 (5.2.4 - SDK 10.4) Support
      [not loaded] com.seagate.driver.PowSecLeafDriver_10_5 (5.2.4 - SDK 10.5) Support
      [not loaded] com.seagate.driver.SeagateDriveIcons (5.2.4 - SDK 10.4) Support
      [loaded] com.sophos.kext.sav (9.1.55 - SDK 10.7) Support
      [loaded] com.sophos.nke.swi (9.1.50 - SDK 10.8) Support
    Launch Daemons: ?
      [loaded] com.adobe.fpsaud.plist Support
      [loaded] com.microsoft.office.licensing.helper.plist Support
      [running] com.sophos.autoupdate.plist Support
      [running] com.sophos.configuration.plist Support
      [running] com.sophos.intercheck.plist Support
      [running] com.sophos.notification.plist Support
      [running] com.sophos.scan.plist Support
      [running] com.sophos.sxld.plist Support
      [running] com.sophos.webd.plist Support
      [running] com.trusteer.rooks.rooksd.plist Support
    Launch Agents: ?
      [loaded] com.divx.dms.agent.plist Support
      [loaded] com.divx.update.agent.plist Support
      [running] com.sophos.uiserver.plist Support
      [running] com.trusteer.rapport.rapportd.plist Support
    User Launch Agents: ?
      [loaded] com.adobe.ARM.[...].plist Support
      [running] com.amazon.music.plist Support
      [loaded] com.google.keystone.agent.plist Support
      [not loaded] jp.co.canon.Inkjet_Extended_Survey_Agent.plist Support
    User Login Items: ?
      iTunesHelper
      TomTomHOMERunner
      AdobeResourceSynchronizer
      Dropbox
    Internet Plug-ins: ?
      FlashPlayer-10.6: Version: 15.0.0.152 - SDK 10.6 Support
      DivX Web Player: Version: 3.2.1.977 - SDK 10.6 Support
      AdobePDFViewerNPAPI: Version: 11.0.09 - SDK 10.6 Support
      AdobePDFViewer: Version: 11.0.09 - SDK 10.6 Support
      Flash Player: Version: 15.0.0.152 - SDK 10.6 Support
      EPPEX Plugin: Version: 10.0 Support
      Default Browser: Version: 537 - SDK 10.9
      OVSHelper: Version: 1.1 Support
      QuickTime Plugin: Version: 7.7.3
      SharePointBrowserPlugin: Version: 14.4.4 - SDK 10.6 Support
      iPhotoPhotocast: Version: 7.0 - SDK 10.7
    Safari Extensions: ?
      Ultimate
    Audio Plug-ins: ?
      BluetoothAudioPlugIn: Version: 1.0 - SDK 10.9
      AirPlay: Version: 2.0 - SDK 10.9
      AppleAVBAudio: Version: 203.2 - SDK 10.9
      iSightAudio: Version: 7.7.3 - SDK 10.9
    iTunes Plug-ins: ?
      Quartz Composer Visualizer: Version: 1.4 - SDK 10.9
    3rd Party Preference Panes: ?
      Flash Player  Support
      Perian  Support
      Trusteer Endpoint Protection  Support
    Time Machine: ?
      Skip System Files: NO
      Auto backup: YES
      Volumes being backed up:
      Macintosh HD: Disk size: 297.29 GB Disk used: 160.38 GB
      Destinations:
      Data [Network] (Last used)
      Total size: 2 TB
      Total number of backups: 99
      Oldest backup: 2012-04-20 17:05:32 +0000
      Last backup: 2014-09-18 23:49:25 +0000
      Size of backup disk: Excellent
      Backup size 2 TB > (Disk size 297.29 GB X 3)
      Time Machine details may not be accurate.
      All volumes being backed up may not be listed.
    Top Processes by CPU: ?
          6% InterCheck
          5% iCalExternalSync
          3% WindowServer
          2% CalendarAgent
          2% SystemUIServer
    Top Processes by Memory: ?
      152 MB SophosScanD
      147 MB InterCheck
      106 MB SophosAntiVirus
      66 MB Dropbox
      57 MB com.apple.iTunesLibraryService
    Virtual Memory Information: ?
      161 MB Free RAM
      1.55 GB Active RAM
      1.41 GB Inactive RAM
      902 MB Wired RAM
      611 MB Page-ins
      0 B Page-outs

    Uninstall Trusteer software
    http://www.trusteer.com/support/uninstalling-rapport-mac-os-x
    Remove Sophos
    https://discussions.apple.com/message/21069437#21069437

  • I've just signed up to iTunes Match as I have songs on my iPhone 4 which wont sync with iTunes as they are from CDs but I can't see my music in the cloud now. Anyone had the same problem and have an easy fix?

    I've just signed up to iTunes Match as I have songs on my iPhone 4 which wont sync with iTunes as they are from CDs but I can't see my music in the cloud now. Anyone had the same problem and have an easy fix?

    What fixed it for me:
    On your computer, open iTunes > My iPhone (or whatever name you gave your iPhone) > "Music" page
    Uncheck "Sync Music"
    Click "Sync" button (bottom right)
    Let it run and finish
    Uncheck the box for every song, playlist, etc.
    Click "Sync" button (bottom right) (This step may be unnecessary, but I did it and got the result I wanted.)
    Let it run and finish
    Check the boxes for the music you want on your iPhone
    Click "Sync" button (bottom right)
    Let it run and finish
    See if that doesn't work for you.  I tried a lot of things that did nothing, but this seems to have fixed it, and quickly.

  • Having horrible service with 4GLTE I have had 3G for several weeks (I am not the only person I know having this problem), I have reset my network settings and it did not resolve the issue.  I am also unable to send SMS and text messages without them eithe

    Having horrible service with 4GLTE I have had 3G for several weeks (I am not the only person I know having this problem), I have reset my network settings and it did not resolve the issue.  I am also unable to send SMS and text messages without them either failing or not sending at all.  Is there an outage in the Cleveland, Ohio area (zip codes 44129, 44134, 44137) or anything else I can do to resolve this issue?

    Not that I'm a Verizon employee, but I have experience in the field. An LTE tower will only extend up to, on a perfect day, with no elevation, 6-7 miles. On a typical day, you will be lucky at four (4) miles. The three ZIP codes you've given are all within about a 12 mile radius. That would mean that 2-3 towers are currently down at the same time, and Verizon would know about it within the hour. Being it's Cleveland, I'm sure they would receive numerous calls regarding an outage of that size.
    My point is that if you're having issues in all three ZIP codes, chances are it's a phone issue. If you're handset is simply not receiving LTE, but still receiving 3G, that would signify a SIM card issue. You need to get your SIM card replaced.

  • Itunes won't open and i am getting this error message: the application itunes quit unexpectedly. the problem may have been caused by the libgnsdk_dsp.1.9.5.dylib plug in

    Have not changed any settings on my mac. Quit the application end of the day. The next day I went to start it and it won't open. Everytime I try to launch it, it won't open and I get this error message: The application itunes quit unexpectedly. The problem may have been caused by the libgnsdk_dsp.1.9.5.dylib plug in

    Have not changed any settings on my mac. Quit the application end of the day. The next day I went to start it and it won't open. Everytime I try to launch it, it won't open and I get this error message: The application itunes quit unexpectedly. The problem may have been caused by the libgnsdk_dsp.1.9.5.dylib plug in

  • I'm using an iPhone 4 after upgrading to iOS 5 i'm getting an error 1635 now i'm facing problems syncing my contacts and facing many problems, i have restored my iPhone but still i'm getting the same error

    i'm using an iPhone 4 after upgrading to iOS 5 i'm getting an error 1635 now i'm facing problems syncing my contacts and facing many problems, i have restored my iPhone but still i'm getting the same error

    Did you check your security software settings? eliminating conflicts from third-party security software.

Maybe you are looking for