• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Daemon problem

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hallo,
I am new to Java and I am programming with multiple daemons are running parallel. I have one problem. i used each daemon with synchronization.master daemon is always waiting for data from slave daemons.

master daemon {
synchronized (datareceived) {
while(processrunning) {
datareceived.wait();
do some process with data
}
}

slave daemon1 {
synchronized (datareceived) {
while(processrunning) {
ReadData;
datareceived.notify();
}
}

slave daemon2 {
synchronized (datareceived) {
while(processrunning) {
ReadData;
datareceived.notify();
}
}


The problem is if master daemon is not at the position of wait and if one of slave did send notify(), then i am loosing the notification.

What I want is, i should not loose any notification. I should respond on each notification. So please let me know if somebody can help regarding

Thank you,

Regards,
Dimpu
 
Ranch Hand
Posts: 116
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like you need to queue the results and then let the master thread pick elements off the queue as they become available. If you are running Java 1.5 or later take a look at java.util.concurrent.BlockingQueue. If you are running 1.4 or earlier you'll have to implement something similar yourself.
 
Sashi Gundoji
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your message. I am using lesser version of JDK. I am not able to look into java code even in JDK1.5.

Eclipse is showing below message:
Source not found
The jar file rt.jar has no source attachment.
You can attach the source by clicking Attach Source below

I tried to locate rt.jar, but still that does not help me. So could you please tell me how I can see the source code.

thanks,

Regards,
Sashi
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That Eclipse error message means that you were trying to look at the source code of the standard Java API classes. Did you do what Eclipse suggested to you: "You can attach the source by clicking Attach Source below"?

You have a file src.zip in your JDK directory which contains the source code of the standard Java classes. You can tell Eclipse where that src.zip file is, so that it can show you the source code.
 
money grubbing section goes here:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic