Created
October 24, 2017 19:56
-
-
Save javamultiplex/5d6ec82c3fe3792dcfcc088b2c9f97b8 to your computer and use it in GitHub Desktop.
Example of IllegalArgumentException present in java.lang package.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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