Solved

using synchronized

Posted on 2003-10-21
2
185 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bigHeights  challenge 13 56
countX 22 70
Books that can get me started on JAVA 2 56
java set up 1 47
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler 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 …

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now