Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8790451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:39:23+00:00 2026-06-13T22:39:23+00:00

can you please explain to me this piece of java code? I cannot understand

  • 0

can you please explain to me this piece of java code? I cannot understand this syntax.

synchronized (this) {
              try {
                  wait(endTime - System.currentTimeMillis());
              } catch (Exception e) {
              }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:39:25+00:00Added an answer on June 13, 2026 at 10:39 pm

    It means that this block of code is synchronized meaning no more than one thread will be able to access the code inside that block.

    Also this means you can synchronize on the current instance (obtain lock on the current instance).

    This is what I found in Kathy Sierra’s java certification book.

    Because synchronization does hurt concurrency, you don’t want to synchronize
    any more code than is necessary to protect your data. So if the scope of a method is
    more than needed, you can reduce the scope of the synchronized part to something
    less than a full method—to just a block.

    Look at the following code snippet:

    public synchronized void doStuff() {
        System.out.println("synchronized");
    }
    

    which can be changed to this:

    public void doStuff() {
       //do some stuff for which you do not require synchronization
       synchronized(this) {
         System.out.println("synchronized");
         // perform stuff for which you require synchronization
       }
    }
    

    In the second snippet, the synchronization lock is only applied for that block of code instead of the entire method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please explain what #ifdef..#else..#endif does in this piece of code? It's from
Can anyone please explain to me whats wrong with this piece of code and
Can some one please explain to me why this piece of code prints out
Can someone please explain this piece of code which I have tried to decipher?
Can anyone please explain the behavior of this piece of code(from http://blogs.msdn.com/b/wesdyer/archive/2007/02/02/anonymous-recursion-in-c.aspx ). I
Can someone please explain this bit of piece of code? Thanks. alert({foo:test foo, bar:test
Can someone please explain this piece of code? struct Class { boost::function<void()> member; };
Can you please explain what this piece of C++ code does: int main() {
Can someone please explain why I'm getting this error Type mismatch: cannot convert from
Can somebody please explain to me the meaning of this line of code? val

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.