Skip to content
Snippets Groups Projects
Commit 2308f2e0 authored by Eckl, Máté's avatar Eckl, Máté
Browse files

5. labor kicsit javítva

A notify-okat raktam kicsit arrébb, mert így egy kicsivel hatékonyabb. Ha azelőtt notify-olnék, hogy belerakom/kiveszem az elemet a FIFOból, akkor felkelne, majd a while miatt visszamenne rögtön aludni, és csak egy későbbi körben értesülne megint, ez pedig pazarlás.
parent 1b717f4d
No related branches found
No related tags found
No related merge requests found
...@@ -7,3 +7,4 @@ dist/ ...@@ -7,3 +7,4 @@ dist/
manifest.mf manifest.mf
nbproject/ nbproject/
n-ary tree/ n-ary tree/
NHF/
...@@ -10,9 +10,9 @@ public class Fifo{ ...@@ -10,9 +10,9 @@ public class Fifo{
System.out.println("put: " + Thread.currentThread()); System.out.println("put: " + Thread.currentThread());
while(s.size()>=10) while(s.size()>=10)
this.wait(); this.wait();
this.notify();
s.add(e); s.add(e);
System.out.println("produced" + " " + e + " " + this.notify();
System.out.println("produced " + e + " " +
System.currentTimeMillis() % 10000); System.currentTimeMillis() % 10000);
} }
...@@ -21,9 +21,9 @@ public class Fifo{ ...@@ -21,9 +21,9 @@ public class Fifo{
System.out.println("get: " + Thread.currentThread()); System.out.println("get: " + Thread.currentThread());
while(s.size()<=0) while(s.size()<=0)
this.wait(); this.wait();
this.notify();
String ret=s.get(0); String ret=s.get(0);
s.remove(ret); s.remove(ret);
this.notify();
return ret; return ret;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment