• 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:

Interface question

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

i want to to use an interface to nofify from one class to another(both classes are unrelated) that a process has finished.
I would like to know if is possible to do that with an interface or if there is a better way to do it.

thanks in advance
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An interface is a contract that says any implementing class must implement the methods defined in the interface. It can't include any code to actually send and receive messages.

That said, creating an interface to define the notification methods is a good idea. An interface is a nice abstraction. The JDK includes an Observer interface along with an Observable class that might do the job for you. Look into the JavaDoc and see if they'll fit.

Before I learned about Observable/Observer I wrote my own little pub-sub routine - a one-abstract-class-framework. If Observable doesn't work out for you I'd be happy to discuss my code. We usually don't hand out complete solutions in this forum - it's much more fun and educational if you work out the tricky bits yourself. So see what you can get going, post some code, we'll talk some more.
[ April 04, 2005: Message edited by: Stan James ]
 
Space pants. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic