How to set or change priority of Main Thread?

As already specified, you need to use setPriority() and getPriority() methods of Thread class to change and to retrieve priority of a Thread. However, first we need to get the Thread object of main Thread. This can be achieved using Thread.getCurrentThread(), which returns Thread object of the current Thread. Below is snippet of code

public class MainThreadPriority {
	public static void main(String[] args) {
		Thread t = Thread.currentThread();
		
		System.out.println("Priority of "+t.getName()+" thread is: "+t.getPriority());
		
		t.setPriority(Thread.MAX_PRIORITY - 2);
		
		System.out.println("Now, Priority of "+t.getName()+" thread is: "+t.getPriority());
	}
}

You may also like to read:
All Threads examples

Hibernate HQL, how to retrieve selected fields

Below example code shows how to retrieve selected fields from database. As shown below a List of Object[] is being returned, by session.query(“SELECT Y.firstName, Y.lastName FROM Employee Y WHERE Y.salary >9000”);

Then List need to be iterated, in which each element is an Object array of size 2(since only two fields are being selected). You can download full NetBeans project sour code here.

import org.hibernate.HibernateException; 
import org.hibernate.Transaction;
import org.hibernate.Session;
import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HQLManageEmployee {
   private static SessionFactory factory; 
   public static void main(String[] args) {
      try{
          //step 1: Create Session Factory
         factory = new Configuration().configure().buildSessionFactory();
      }catch (Throwable ex) { 
         System.err.println("Failed to create sessionFactory object." + ex);
         throw new ExceptionInInitializerError(ex); 
      }
      HQLManageEmployee ME = new HQLManageEmployee();

      /* List down all the employees */
      ME.listEmployees();
   }

   /* Method to  READ all the employees */
   public void listEmployees( ){
      Session session = factory.openSession();
      Transaction tx = null;
      try{
         tx = session.beginTransaction();

         Query qry = session.createQuery("SELECT Y.firstName, Y.lastName FROM Employee Y WHERE Y.salary >9000");

          List<Object []> employees = qry.list(); 
         for (Iterator iterator = 
                           employees.iterator(); iterator.hasNext();){
            Object [] emp =  (Object [])iterator.next(); 

            System.out.println(emp[0]+" --- "+emp[1]);
         }
         tx.commit();
      }catch (HibernateException e) {
         if (tx!=null) tx.rollback();
         e.printStackTrace(); 
      }finally {
         session.close(); 
      }
   }
}

Example HibernateHQL