Use of synchronized in constructor for accessing static SimpleDateFormat

Just a little confused. I have
private static final SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
in my class. I made dateFormat static final, because its a costly operation that I dont want to do more than once. I access dateFormat in the constructor of my class to format a date. Since SimpleDateFormat is not threadsafe, my understanding is the access has to happen in synchronized block to ensure thread-safety, as follows
public MyClass (date) {
synchronized(dateFormat) {
dateFormat.format(new Date());
Is that right? I know that constructors dont need to be synchronized because they are object creations, hence cant have multiple threads stepping on one another. But since dateFormat is a static field, doesnt it need to be protected, inspite of the above argument? Would appreciate responses/comments. Thanks

this constructor constructs a log record and uses the dateformatter to add timestamp to the log. It is executed very frequently. My tests indicate that using a static dateformatter is better performing than using a new formatter per thread. I am including the results below. 'u method' stands for unsynchronized (new formatter for each thread) and 's method' for synchronized (with static formatter)
run completed, took [ 10] milliseconds to format date, using 'u method' for [ 1] threads
run completed, took [ 0] milliseconds to format date, using 's' method for [ 1] threads
run completed, took [ 10] milliseconds to format date, using 'u method' for [ 10] threads
run completed, took [ 0] milliseconds to format date, using 's' method for [ 10] threads
run completed, took [ 40] milliseconds to format date, using 'u method' for [ 50] threads
run completed, took [ 30] milliseconds to format date, using 's' method for [ 50] threads
run completed, took [ 70] milliseconds to format date, using 'u method' for [ 100] threads
run completed, took [ 40] milliseconds to format date, using 's' method for [ 100] threads
run completed, took [ 260] milliseconds to format date, using 'u method' for [ 500] threads
run completed, took [ 170] milliseconds to format date, using 's' method for [ 500] threads
run completed, took [ 491] milliseconds to format date, using 'u method' for [ 1000] threads
run completed, took [ 310] milliseconds to format date, using 's' method for [ 1000] threads
run completed, took [ 1793] milliseconds to format date, using 'u method' for [ 5000] threads
run completed, took [ 1472] milliseconds to format date, using 's' method for [ 5000] threads
run completed, took [ 3164] milliseconds to format date, using 'u method' for [ 10000] threads
run completed, took [ 2524] milliseconds to format date, using 's' method for [ 10000] threads
run completed, took [ 14571] milliseconds to format date, using 'u method' for [ 50000] threads
run completed, took [ 12819] milliseconds to format date, using 's' method for [ 50000] threads
run completed, took [ 28050] milliseconds to format date, using 'u method' for [ 100000] threads
run completed, took [ 25107] milliseconds to format date, using 's' method for [ 100000] threads

Similar Messages

  • I created a new apple id for my iphone and ipad which work great and allow me to access Icloud. on my macbook air can't get it to use my new apple id for icloud. Help?

    I created a new apple id for my iphone and ipad which work great and allow me to access Icloud. on my macbook air  I can't get it to use my new apple id for icloud. It keeps going back to my old apple id and doesn't afford me to alter it. I use system preferences-icloud and it just wants to verify the old apple id but doesn't afford me the opportunity to delete teh account or edit it like the iphone5 and ipad. Help?

    Welcome to the Apple Community.
    You need to use the sign out option on the left side.

  • Simple question:  I want to use iCloud as a back up disk for my documents folder.  How can I do this?  If I cannot do this, why am I paying for access to "the cloud?"

    Simple question:  I want to use iCloud as a back up disk for my documents folder.  How can I do this?  If I cannot do this, why am I paying for access to "the cloud?"

    iCloud does not provide general file storage or backup, so you cannot back up your Documents folder using it. You will need to find a third-party alternative - this page examines some options (some are free):
    http://rfwilmut.net/missing3
    iCloud at basic level, with 5GB is storage, is free: you only pay anything if you want to increase the storage space.

  • Using Eudora or Netscape7 for non-verizon email accounts with FIOS for access

    Since Verizon does not give tech support to 3rd party email clients, and using a non-Verizon email account creates additional problems, I decided to share what I learned the very hard way....certainly with no help whatever from Verizon tech support.
    First of all, there may have been a time (a day, a month, some random nanosecond) when you had to change the port to 587 it is no longer the case.  Port 25 works just fine, and in fact 587 no longer works in most cases.  So ignore tech support's claim that all you have to do is change the port number to 587...don't do it.
    And so long as you want to use a pop account other than verizon for your incoming email you will have to use what is referred to as SMTP Relay.  Verizon tech support will tell you that Verizon no longer supports SMTP Relay, and technically speaking that is true, but Verizon SMTP Relay is not what you need anyway.  What you need is to use the SMTP Relay facility of your Email Client, in my case Eudora and (for my wife) Netscape 7.
    Now before you can actually do anything you will have to have a valid Verizon email account, even if you never plan to actually use your verizon email address.  That means before you can set up your email client you must have a verizon email address. The tech who installed my FIOS supposedly set up my computer, which meant I had internet access, but he didn't set up the verizon email address.  I wasted 2 days before this came to light...so just make sure you have one before starting.
    Netscape 7.0  has an email client my wife has used forever so I had to make it work for Verizon FIOS.  Fortunatly they have a built in SMTP Relay facility (although they never call it that).  You set up your pop (incoming) server the way you always have.  In my our email accounts are on Earthlink, so you use the earthlink POP server for your incoming email.  If you are switching from whatever you have to Verizon FIOS, you will already have that set up anyway.  But you will have to change the SMTP server address to outgoing.verizon.net    and you will have to click the box that says Use Authentication, with  User Name and Password.  You will put into the User Name your verizon email account except without the .verizon.net    And the first time you use this Client to send email it will ask your for your password (use your Verizon password) and you should check the box that says to remember this password.    This will make everything work fine.  You will see on the SMTP Server information page a box that allows you to fill in the port.  If you leave it blank it will use port 25.  If you put in another port number it has to be right, and what is the correct number keeps changing based on which verizon person you talk to.  I found that 25 works, although they say it won't, and that others don't work, although they say they will.
    To Use Eudora (as i do)  first you have to be using the latest version 7.1 because it appears to be the first one that truely supports SMTP Relay. That's a free download if you don't have it.   Then you have to use multiple personalities.  Effectively you set up one personality (go to to tools and click on personalities) which is your normal email account (ie not your verizon one).  This is used for everything with the exception of the SMTP Server interaction.  YOu then set up a second personality which is for your Verizon email account. Be aware that you can still have that account use your normal email return address so folks who receive email from you can reply to your normal email address.  You can, independantly from that set up your incoming email pop account to be either your normal one or your verizon incoming email account (I do it the later way so I can receive something actually sent to my Verizon account, although I never give that out.  But now the important thing is that you set up your SMTP server to be outgoing.verizon.net  set up User Name to be your verizon email account but without the verizon.net and click on Authentication Allowed and Use Relay Personality.  Don't click on Use submission port 587, like I said you want to use 25, but if verizon has changed that yet again no problem as you can set up the port to use independantly using the Tools/Options/Ports , and finally you go to the Tools/Options/SendingMail stuff and select the SMTP Relay Personality to be the one that is set up for the Verizon email account.  That means your client will operate using your primary personality for everything except the SMTP part and for that it will get all its parameters from the Relay Personality. 
    This all worked.

    I use Eudora a my email client and routinely receive both my Verizon and ATT emails. 
    The last email I received  from my Verizon account was at 10:30pm on August 5.  I cannot send emails from Eudora at all either.
    My Verizon DSL email account is active through Verizon-Florida at my home there.  I am currently at my Ohio home and the DSL account is with Frontier which purchased Verizon here in Ohio.
    Does anyone know what might have happened to have resulted in my emails not being sent to or from my Eudora Client?

  • A family member recently downloaded an iBook on my device using their apple I'd. Now I don't have access to the material I've purchased using my apple I'd for 90 days! So frustrated! Any tips?

    A family member recently downloaded an iBook on my device using their apple I'd. Now I don't have access to the material I've purchased using my apple I'd for 90 days! So frustrated! Any tips? ITunes won't allow me to download the books I've paid for!!

    That wasn't something that I was aware of, but looking at this http://support.apple.com/kb/HT4627 I'm not sure that there is much you can do about the device itself. I'm also not sure whether it only affects downloading directly on the device itself or whether you can connect the iPad to your computer and sync content across to it from your account that way - or even whether restoring back to factory defaults on the iPad will bypass the 90 days

  • I run a mac air on a single user account but multiple people using it, which is ok for the situation. All have their accounts in the apple mail app. what is missing for me is a separate password to access the mail account. otherwise anyone can see anyones

    I run a mac air on a single user account but multiple people using it, which is ok for the situation. All have their accounts in the apple mail app. what is missing for me is a separate password to access the mail account. otherwise anyone can see anyones
    Any clue, how i can add a mail account to apple mail app, but with separate password / pin to open it.
    Years ago there was a program called mail switcher which added this functionality, but thats gone.
    cheers
    Tom

    They would have to be logged in as separate users in order not to see your account in Mail. Whatever accounts put in Mail under your account will show up. All mail accounts usually have there own user and password. The only thing you can do is to remove the password from Keychain and take the account offline so you don't keep getting prompts for passwords each time it checks for mail.
    Not a great solution.
    Best way is to give the other user their own user account with their own mail and enable fast user swithcing to log between the different users if all access the computer frequently.

  • I have an iPhone with an unlimited data plan. Is there a way to go online with a wifi only iPad using my phone for access?

    I have an iPhone with an unlimited data plan. Is there a way to go online with a wifi only iPad using my phone for access?

    If your iPhone cell carrier allows you to use Tethering, you can turn your iPhone into a wifi hotspot, then your iPad Air can connect to that for internet access.  Not all cell carriers allow tethering without you signing up for additional fees/services.  For example, AT&T in the US still has grandfathered "unlimited" data plans, but they do not allow tethering for those plans.  With AT&T you need to switch to a Mobile Share plan (or a tiered plan if still available) to use tethering (legally).

  • Procedure  for  Accessing  WebService in ejb By using NetWeaver,

    hai,
    This is Guru.
    please tell me the procedure for accessing a webservice in ejb .
    my mean is.
    i have one Session Beab,And there is one webservice.
    How can i  call and using  that webservice in netweaverdeveloperstudio tool.please send me code,if u have.
                                        thanqq
                                         Guru

    Hi Guru,
    the procedure to use a WS is as follow
    1. Use the SAP xmltoolkit and generate client binding for your WS, which is the stub class, parameter and return type classes of the WS methods, if any.
    2.Import the created WS client jar from step 1 to your EJB module project
    3. In your session bean: instantiate the stub and call a WS method on this stub
    That's all there is to it.
    Best Regards
    Gregor
    Ps. The NWDS Help has also tutorial regarding WS usage.

  • If i create a partition for Windows 7, and boot up in Windows using Boot Camp, can I still access the files from the Mac partition (Photo's Music etc.)

    If i create a partition for Windows 7, and boot up in Windows using Boot Camp, can I still access the files from the Mac partition (Photo's Music etc.)

    JDFitch wrote:
    Ok Great,
    Will installing Boot Camp drivers allow me to both read and write to the OS X Volume from windows?
    This is important as if it will it means i can make the windows partition a lot smaller and keep all my files on the OS X partition which would be preferable.
    Jon
    No, OSX will be read only (from Windows) and vice versa. (you can install 3rd party utilities on either or both partitions, to make read/write possible)

  • I have been using yahoo mails from iPad for several months. Today I am unable to access my mails even though I logged in to yahoo....the signin screen is keep coming when I tried to access mail.....is it due to iPad or yahoo?

    I have been using yahoo mails from iPad for several months. Today I am unable to access my mails even though I logged in to yahoo....the signin screen is keep coming when I tried to access mail.....is it due to iPad or yahoo?

    It sounds like you might need to contact Yahoo! if you aren't able to setup your email account as a new account after deleting it. 
    I found some links on the Yahoo! website that might help:
    http://help.yahoo.com/kb/index?page=content&id=SLN4138&locale=en_US&y=PROD_MOBIL E
    http://help.yahoo.com/kb/index?locale=en_US&y=PROD_MOBILE&page=content&id=SLN261 7

  • Method :Want to Use Z-Table for Accessing Data

    Dear All,
      I am new to BADI. I have implented one HR-PAYROLL Badi.
      In this BADI I am having one method . I want to Use One Z-table for accessing data from
      that table . Not able define the table in method.
      Kindly tell me how to do it .
      Thanking you in Advance
      Siladitya

    Hello Siladitya
    I assume your problem is the definition of an itab for selecting data from your Z-table. In case of classes you have to use table types and workareas, e.g.:
    METHOD name_of_interface_method.
    DATA:
      lt_itab    TYPE TABLE OF <name of z-table>,
      ls_record  TYPE <name of z-table>.
      SELECT * FROM <name of z-table> INTO TABLE lt_itab.
      LOOP AT lt_itab INTO ls_record.
      ENDLOOP.
    ENDMETHOD.
    Regards
      Uwe

  • 1) which SVN for Access dev? 2) alternative for use on peer-to-peer network ?

    a - As I understand it typical SVN solutions require a server on your network... true?
    b - Which SVN solution should we consider for keeping up with Access development revisions, etc?
    c - Is there a solution that will work on a peer-to-peer network?
    d - Free alternatives and low coast alternatives are?
    thanks for any help.

    > As I understand it typical SVN solutions require a server on your network
    Sure, “typical” means “many”, so yes. However many others are file based and ONLY require a share folder and thus don't require a server. And then from that shared folder you can often use add-ons to sync that folder to web based systems like GitHub. So
    you can "mix" such file only systems and then over time use web based server with that system that does not require a server, but only a shared folder.
    >Which SVN solution should we consider for keeping up with Access development revisions, etc.?
    Actually, you can just simply “copy” the current version to some folder before you “release” that version. So copy and add a “version” number to the accDB file. If you application is MyInvoice.accDB, then copy to server with MyInvoice-1044.accDB (verison
    1044). Since Access is a “single” file, then this works rather well compared to other systems that have “many” files. In fact I copy both the accDB, and the compiled version accDE to a folder on the server (with version number added to the file name as per
    above). Thus you can go back to any previous version with great ease.
    However, you might be talking about source code control in addition to versioning of software. (often the term is interchanged, but it should not be). Source code control (SCC) is a “common” means to achieve versioning of software, but ALSO allows multiple
    developers to work on the project at the same time (collaboration). So there is a big difference between SVN, and SCC.
    Access for a VERY long time has supported Microsoft “standard” source code control interface. While Access is a “single” file, Access is able to “logically” view each application part as a separate file. So the fact of “one” file, or “many” files does not
    matter – say no more then a zip file is “one” file, but inside there are “many” files! So SCC is 100% possible in Access, and since Access has a resolution down to an object by object basis? Then developers can check-in/out individual forms, query
    code modules etc.
    Access versions all the way up to 2010 support the “standard” Source Code interface.
    So:
    Using GitHub you see this:
    Using VSS, you see this:
    Note that using Git, TFS, VSS etc, they ALL give the above UI with check boxes beside each object, and all give a cool "check in/check out" right click context menu not shown above.
    The above Git shot is running in "file mode" without a server. Visual Source Safe is also file based, but VERY old and quote hard to find now.
    So the great news is that Access has for a very long tie supported SCC, and thus is a great way to “version” your software. And Access will show you OBJECTS that are checked in/out by you as per above with the check mark and lock icon.
    So inside of the access GUI you could with any SCC system that supports the standard SCC interface would know what objects are locked and you not taken ownership of. (note the "lock" and "check mark" icon beside each object.
    However, Access 2013 dropped support for SCC. So all of the above cool options are NOT available for 2013.
    Since Access is a “single” container, then versioning tends to be rather easy. Just copy the file to a folder with a version number appended to the file name, and you are done!
    You not distinguished between versioning of your software, and that of source code control – so it not clear if you looking to just keep versions of your software, or allow team development on your application?
    While SCC will give you versioning, it also allow multiple developers to work on the same application at the same time (collaboration). SVN does not necessary give you this multiple developer ability.
    As noted, versioning for Access is easy - just copy the accDB (front end) to a folder on the server with a version number appended to the file name. Works quite well. I have a table in the front end with a version number, and a version number in the back
    end table. My deployment code reads that version number and copies the files to the server for me.
    (It is assumed that you have a split database).
    However, if for 2013 you need both versioning and SCC (say to allow multiple developers), then you likely have to roll your own. I would suggest using “save-as text” command to export all access objects to a folder, and THEN use one of MANY source code control
    systems that operate on that folder. Such a setup could easily be cobbled together in an afternoon of your time. And “many” SCC systems provide a GUI that is external to the developer tools/environment. This would allow you to use free tools like Git and GitHub.
    For just versioning of your software? Then SCC is likely overkill, and if you using Access 2013, then you cannot use standard SCC providers anymore anyway.
    Albert D. Kallal (Access MVP)
    Edmonton, Alberta Canada

  • We are using apple tv to try to access our itunes account on the computer.  We see our library of music but when we click on the song it searches for a long time and then says that it cannot access the itunes store.  Any ideas on what we are doing wrong?

    We are using apple tv to try to access our itunes account on the computer.  We see our library of music but when we click on the song it searches for a long time and then says that it cannot access the itunes store.  Any ideas on what we are doing wrong?

    Welcome to the Apple Community.
    Try the following steps, check whether things are working after each step where appropriate, before trying the next.
    Restart the Apple TV (Settings > General > Restart).
    Restart the Apple TV by removing ALL the cables for 30 seconds.
    Restart your router.
    Reset the Apple TV (Settings > General > Reset > Reset all settings)
    Restore the Apple TV (Settings > General > Reset > Restore)

  • I do not see any icon for accessing groups next to my tabs as indicated in the help. I have to use the shortcut keys.

    I am using Windows XP SP3. In the help for Firefox 5 it indicates icons on the screen to click like the one in far right of the tab bar for access the groups. I have never seen these so not sure if they don't load for my setup or whether I just need to switch them on somewhere (cannot find anything in the menus applicable).
    Does Firefox 4 and 5 look different for some operating systems?

    You can also find a link to open Tab Groups in the drop down list of the List all Tabs button at the right end of the tab bar (Shift+Ctrl+E).

  • "There was an error loading the preference bundle for accessibility" it appears when i open my accessibility, that is why i cant use my assistive touch

    "There was an error loading the preference bundle for accessibility" it appears when i open my accessibility

    We had the same issue after applying the SP2 & August CU. we open the case with MSFT and get the same resolution as you mentioned.
    I blog about this issue and having the office reference.
    Later MSFT release the Hotfix for this on December 10, 2013 which i am 100% positive should be part of future CUs.
    So if you apply the April CU then you will be fine.
    Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog

Maybe you are looking for

  • Itunes gives me an error message when i try to update iphone

    Im trying to update my iphone on itunes and it gives me an error message everytime, what am i doing wrong? I have the latest verison of itunes.

  • FileUpload get filename and PATH?

    Hi everybody, is there a chance to get also the path from where to upload a file using the fileupload-UI? Thanks a lot Regards Mario

  • Peer to Peer Airplay w Apple TV and iPhone?

    I want to do peer to peer screen sharing from my iphone 5 (ios 8.1) to my new Apple TV (model A1469, 7.0.1 (6912) software). We don't have WIFI in the office and that's why I want to do peer to peer.  I can't get my phone to find the Apple TV when I

  • Unicode (Chinese) As Input In Global_AddressCleanse Transformation

    Hi All, Is it possible to use Unicode fields as input () for Global Address Transformation. I am using Data Service 3.0. If I use unicode fields as data input , Data Services does not perform any cleaning , infact it does give the output fields itsel

  • Report / Log for skipped recovery files

    Hello, I am hoping someone might be able to point me in the correct direction to locate some data. A colleague of mine performed a recovery on a file directory early this morning. When selecting the option for the restore he selected "SKIP" for "Exis