Md Husain
BAN USERThis can be done by Double locking with synchronized block:
public static Singleton getInstance()
{
if (instance == null)
{
synchronized(Singleton.class)
{
if (instance == null)
{
System.out.println("getInstance(): First time getInstance was invoked!");
instance = new Singleton();
}
}
}
return instance;
}
can you please tell me how you are keep an account of minimum range in this. How you are going to find out which range is minimum because you going forward without keeping the record of range.
for instance: If you are taking an array for tracking the records then each time you have to find the smallest element of the array and you have to compare it with current result and so on .... till you are getting minimum.
I m taking array here only for explanation, for that you can use a heap also. but any how you have to provide extra code to keep track for ranges to find minimum range and the proper possession of each and ever combination with range, for that you require another data structure.
I think they are not asking about the caching system of OS only but they Might be asking about the Caching system which is used in server load balancing system in which for small data we can use hashMap but for huge data we have to use "Memcached" like system in java.
I m not confirm about please correct me if i m wrong.
This is Java Program
inArr is we can create the char array and outPut array.
public class CompressingArray {
int count1=1,i, count2, count3;
char[] inArr = { 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'X', 'X', 'T', 'T',
'T', 'T' };
char[] outArr = new char[20];
public char[] compress() {
for ( i = 0; i < (inArr.length-1); i++) {
if (inArr[i] == inArr[(i + 1)]) {
count1++;
//System.out.println(count1);
} else {
System.out.print(""+(char)inArr[i]+count1);
count1 = 1;
}
}System.out.print(""+(char)inArr[i]+count1);
return outArr;
}
public static void main(String[] args) {
new CompressingArray().compress();
}
}
Bit represents how much memory you can give to a particular process in 64-Bit we can allocate far more memory to particular process then 32-bit. For an instance JVM memory size which is max around 1.5 GB in 32-Bit but we can give far more in 64-bit that is in TBs.
- Md Husain July 03, 2013