Thread Sample - III

package thread2;

/**
 *
 * @author Nurhak
 */
public class Thread2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Worker w1 = new Worker("A");
        Worker w2 = new Worker("B");
        Worker w3 = new Worker("C");
        Worker w4 = new Worker("D");

        w1.setPriority(Thread.MIN_PRIORITY);
        w2.setPriority(Thread.NORM_PRIORITY);
        w3.setPriority(Thread.MAX_PRIORITY);
        w4.setPriority(Thread.MAX_PRIORITY - 2);
        w1.start();
        w2.start();
        w3.start();
        w4.start();
    }
}

package thread2;

/**
 *
 * @author Nurhak
 */
public class Worker extends Thread {

    public Worker(String name) {
        super(name);
    }

    @Override
    public void run() {
        try {
            for (int i = 0; i < 10; i++) {
                System.out.println("Priority --> " + this.getPriority());
            }
        } catch (Exception e) {
            System.err.println("Error occured --> " + e.toString());
        }
    }
}

Comments

Popular posts from this blog

Solution for the fault: "System.Diagnostics.Process.Start is not working on IIS, but working on ASP.NET Development Server"

Solution for "Can not obtain Oracle client information from registry"