10 Ekim 2015 Cumartesi
9 Ekim 2015 Cuma
Thread çok kanallı programlama
class Gorev extends Thread {
int hiz=10;
synchronized void HizDicrement(){
hiz+=10;
}
synchronized void HizIncrement(){
hiz-=5;
}
synchronized public int GetValue(){
return hiz;
}
@Override
synchronized public void run(){
Gorev g=new Gorev();
try {
for (int i = 0; i < 10; i++) {
sleep(1000);
System.out.println(" islem:"+g.getName()+"="+ g.GetValue());
g.HizDicrement();
System.out.println(" islem:"+g.getName()+"="+ g.GetValue());
g.HizIncrement();
}
} catch (Exception e) {
System .out.println(e);
}
}
}
int hiz=10;
synchronized void HizDicrement(){
hiz+=10;
}
synchronized void HizIncrement(){
hiz-=5;
}
synchronized public int GetValue(){
return hiz;
}
@Override
synchronized public void run(){
Gorev g=new Gorev();
try {
for (int i = 0; i < 10; i++) {
sleep(1000);
System.out.println(" islem:"+g.getName()+"="+ g.GetValue());
g.HizDicrement();
System.out.println(" islem:"+g.getName()+"="+ g.GetValue());
g.HizIncrement();
}
} catch (Exception e) {
System .out.println(e);
}
}
}
Kaydol:
Kayıtlar (Atom)