Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Bastet Massri   on Jan 22 In Java Category.

  
Question Answered By: Emma Brown   on Jan 22

In my opinion, it is another argument to discuss whether it could be
used such or not.. the problem here is different..language says wait
method should release the lock and get in a wait state until it is
notified. Java should provide for me.

also i can give an example to the usage of such self waiting and wake
up..think a thread is performing I/O and get blocked. think a method
getData() provide the data after I/O completion. an such a design can
be implement..

class IOThread(){
String data;
.
.
public synchronized getData(){
wait();
return data;
}
public synchronized void notfiyData(){
notify();//data is ready
}

public void run(){
do I/O get Data;
notfiyData();
}

Note: Another point, i am actually using the posted code  like
implementation to create a suspend method  in J2ME. so it is a must
for me.

Share: 

 

This Question has 5 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on A challenging question about Threads&Synchronization Or get search suggestion and latest updates.