Solved

using synchronized

Posted on 2003-10-21
2
188 Views
Last Modified: 2012-05-04
Hi all
is it allowed to use static key in the synchronized block and is the answer is yes is it allowed to use empty string?

public class A
{
       private static key = ""
       
       public A() {
            synchronized (key) {
                    ............
            }
       }
}
0
Comment
Question by:dannysh
  • 2
2 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 40 total points
ID: 9590200
yes, yes
0
 
LVL 35

Expert Comment

by:TimYates
ID: 9590207
>  is it allowed to use empty string

the empty string is still a string object, and synchronized ties to an object, not neccesarially a string with any meaning (or an integer with any value)...
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
tomcat administrtor 12 68
eclipse console opening separately 2 38
SequenceInputStream example 3 22
Java 8 to Java 6 8 33
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question