Solved

using synchronized

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

932 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

11 Experts available now in Live!

Get 1:1 Help Now