Get all display mode

Source code below will display all display mode in your computer include their width, height, refresh rate and bit depth.

********************************************
COMPLETE SOURCE CODE FOR : AllDisplayMode.java
********************************************


import java.awt.GraphicsEnvironment;
import java.awt.GraphicsDevice;
import java.awt.DisplayMode;

public class AllDisplayMode
{
public static void main(String[]args)
{
GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd=ge.getDefaultScreenDevice();
DisplayMode[]allDisplayMode=gd.getDisplayModes();

int temp=0;

while(temp<allDisplayMode.length)
{
System.out.println("DISPLAY MODE : "+(temp+1));
System.out.println("Width : "+allDisplayMode[temp].getWidth()+" pixels");
System.out.println("Height : "+allDisplayMode[temp].getHeight()+" pixels");
System.out.println("Refresh rate : "+allDisplayMode[temp].getRefreshRate()+" Hz");
System.out.println("BitDepth : "+allDisplayMode[temp].getBitDepth()+" bit");
System.out.println("\n");
temp=temp+1;
}
}
}


********************************************
JUST COMPILE AND EXECUTE IT
********************************************

Determine thread hold synchronized lock in java

Source code below will print true if current thread hold synchronized lock for current object and print false for otherwise.

*******************************************
COMPLETE SOURCE CODE FOR : DetermineThreadHoldSynchronizedLock.java
*******************************************


//This program will print three value whether current thread hold synchronized lock
//for cuurent object or not.
public class DetermineThreadHoldSynchronizedLock
{
boolean isLock;

public DetermineThreadHoldSynchronizedLock()
{
//Check whether current thread hold synchronized lock for current object
isLock=Thread.holdsLock(this);

//Print lock value
//It should print false
System.out.println("HOLD SYNCHRONIZED : "+isLock);

//Go to method locker()
locker();
}

public void locker()
{
//Current thread get lock from current object
//It's mean other thread can't interrupt untill this thread get out from
//synchronized block,{}...like below
synchronized (this)
{
isLock=Thread.holdsLock(this);
//Print lock value
//It should print true
System.out.println("HOLD SYNCHRONIZED : "+isLock);
}
lastCheck();
}

public void lastCheck()
{
//Check whether current thread hold synchronized lock for current object
isLock=Thread.holdsLock(this);
//Print lock value
//It should print false
System.out.println("HOLD SYNCHRONIZED : "+isLock);
}

public static void main(String[]args)
{
DetermineThreadHoldSynchronizedLock dthsl=new DetermineThreadHoldSynchronizedLock();
}
}


*******************************************
JUST COMPILE AND EXECUTE IT
*******************************************

RELAXING NATURE VIDEO