Skip to content

Instantly share code, notes, and snippets.

@javamultiplex
Created October 24, 2017 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javamultiplex/5d6ec82c3fe3792dcfcc088b2c9f97b8 to your computer and use it in GitHub Desktop.
Save javamultiplex/5d6ec82c3fe3792dcfcc088b2c9f97b8 to your computer and use it in GitHub Desktop.
Example of IllegalArgumentException present in java.lang package.
package com.javamultiplex.java.lang.exceptions;
/**
* @author Rohit Agarwal
* @version 1.0
* @category java.lang/Exception
* @since JDK 1.0
*/
class MyThread implements Runnable {
@Override
public void run() {
System.out.println(Thread.currentThread().getName());
}
}
public class IllegalArgumentExceptionDemo {
public static void main(String[] args) {
MyThread thread = new MyThread();
Thread th = new Thread(thread);
/*
* IllegalArgumentException will be thrown because Thread priority can
* be 1 to 10.
*
* Thread.MIN_PRIORITY is equivalent to 1 Thread.MAX_PRIORITY is
* equivalent to 10 Thread.NORM_PRIORITY is equivalent to 5
*/
th.setPriority(11);
th.start();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment