Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mammut@ubuntu:~/java$ java Calc
- Exception in thread "main" java.lang.NoClassDefFoundError: Calc
- at gnu.java.lang.MainThread.run(libgcj.so.7)
- Caused by: java.lang.ClassNotFoundException: Calc not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
- at java.net.URLClassLoader.findClass(libgcj.so.7)
- at java.lang.ClassLoader.loadClass(libgcj.so.7)
- at java.lang.ClassLoader.loadClass(libgcj.so.7)
- at java.lang.Class.forName(libgcj.so.7)
- at gnu.java.lang.MainThread.run(libgcj.so.7)
- mammut@ubuntu:~/java$ ls
- Calc.java Prior.class PriorThread.class
- mammut@ubuntu:~/java$
- mammut@ubuntu:~/java$ cat Calc.java
- import java.lang.Thread;
- class PriorThread extends Thread
- {
- static int count = 0;
- int id,mil;
- int max = 200000000;
- PriorThread(int millisek)
- {
- count++;
- id = count;
- mil = millisek;
- }
- public void run()
- {
- try {sleep (mil);} catch (Exception e) {}
- System.out.println("Thread nr." + id + " with priority " + getPriority() + " is starting");
- System.out.println("Thread nr." + id + " calculated " + work()+ "\n");
- if(id == 2)
- {
- System.out.println("\nChanging priority for Thread nr." + id + ". Priority is now 1\n");
- setPriority(1);
- }
- System.out.println("Thread nr." + id + " calculated " + work()+ "\n");
- }
- private float work()
- {
- int i,j;
- float res = 0;
- for(j=1;j<=3;j++)
- {
- System.out.println("Thread nr." + id + " does work()");
- for(i = 1;i < max;i++)
- {
- res += 1.0/(1.0*i*i);
- }
- }
- return(res);
- }
- }
- class Prior
- {
- public static void main(String args[])
- {
- System.out.println("\nStarts two threads !\n");
- PriorThread s1 = new PriorThread(1);
- s1.start();
- s1.setPriority(5);
- System.out.println("Default priority is " + s1.NORM_PRIORITY + " for a thread");
- System.out.println("Max is " + s1.MAX_PRIORITY + " and min is " + s1.MIN_PRIORITY + "\n");
- PriorThread s2 = new PriorThread(3000);
- s2.setPriority(10);
- s2.start();
- }
- }
- mammut@ubuntu:~/java$
Add Comment
Please, Sign In to add comment