Guest User

Untitled

a guest
Apr 23rd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. mammut@ubuntu:~/java$ java Calc
  2. Exception in thread "main" java.lang.NoClassDefFoundError: Calc
  3. at gnu.java.lang.MainThread.run(libgcj.so.7)
  4. Caused by: java.lang.ClassNotFoundException: Calc not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
  5. at java.net.URLClassLoader.findClass(libgcj.so.7)
  6. at java.lang.ClassLoader.loadClass(libgcj.so.7)
  7. at java.lang.ClassLoader.loadClass(libgcj.so.7)
  8. at java.lang.Class.forName(libgcj.so.7)
  9. at gnu.java.lang.MainThread.run(libgcj.so.7)
  10. mammut@ubuntu:~/java$ ls
  11. Calc.java Prior.class PriorThread.class
  12. mammut@ubuntu:~/java$
  13.  
  14. mammut@ubuntu:~/java$ cat Calc.java
  15. import java.lang.Thread;
  16.  
  17. class PriorThread extends Thread
  18. {
  19. static int count = 0;
  20. int id,mil;
  21. int max = 200000000;
  22.  
  23. PriorThread(int millisek)
  24. {
  25. count++;
  26. id = count;
  27. mil = millisek;
  28. }
  29.  
  30. public void run()
  31. {
  32. try {sleep (mil);} catch (Exception e) {}
  33. System.out.println("Thread nr." + id + " with priority " + getPriority() + " is starting");
  34. System.out.println("Thread nr." + id + " calculated " + work()+ "\n");
  35. if(id == 2)
  36. {
  37. System.out.println("\nChanging priority for Thread nr." + id + ". Priority is now 1\n");
  38. setPriority(1);
  39. }
  40. System.out.println("Thread nr." + id + " calculated " + work()+ "\n");
  41. }
  42.  
  43. private float work()
  44. {
  45. int i,j;
  46. float res = 0;
  47. for(j=1;j<=3;j++)
  48. {
  49. System.out.println("Thread nr." + id + " does work()");
  50. for(i = 1;i < max;i++)
  51. {
  52. res += 1.0/(1.0*i*i);
  53. }
  54. }
  55. return(res);
  56. }
  57. }
  58.  
  59. class Prior
  60. {
  61. public static void main(String args[])
  62. {
  63. System.out.println("\nStarts two threads !\n");
  64. PriorThread s1 = new PriorThread(1);
  65. s1.start();
  66. s1.setPriority(5);
  67. System.out.println("Default priority is " + s1.NORM_PRIORITY + " for a thread");
  68. System.out.println("Max is " + s1.MAX_PRIORITY + " and min is " + s1.MIN_PRIORITY + "\n");
  69.  
  70. PriorThread s2 = new PriorThread(3000);
  71. s2.setPriority(10);
  72. s2.start();
  73.  
  74. }
  75. }
  76. mammut@ubuntu:~/java$
Add Comment
Please, Sign In to add comment