Runnable interface declaration

Hello,
Although the function run() is inside the public interface Runnable. its once again declared as abstract. Can i get to know the reason for this ?
Thanks in advance.

Abstract and public have nothing to do with each other.
Every method in every interface is implicitly public and abstract. They can be declared that way or not, but if they are, it's redundant. Some programmers might choose to explicitly declare them public and/or abstract to make it obvious, but it's not necessary and it has no effect.

Similar Messages

  • What is the diffrence between My Runnable Interface and Java Runnable

    Hi folks
    all we know that interfaces in java just a decleration for methods and variables.
    so my Question is why when i create an interface its name is "Runnable" and i declared a method called "run" inside it.then when i implements this interface with any class don't do the thread operation but when i implement the java.lang.Runnable the thread is going fine.
    so what is the diffrence between My Runnable Interface and Java Runnable?
    thnx

    Hi folks
    all we know that interfaces in java just a decleration
    for methods and variables.
    so my Question is why when i create an interface its
    name is "Runnable" and i declared a method called
    "run" inside it.then when i implements this interface
    with any class don't do the thread operation but when
    i implement the java.lang.Runnable the thread is going
    fine.
    so what is the diffrence between My Runnable Interface
    and Java Runnable?
    thnxClasses and interfaces are not identified by just their "name", like Runnable. The actual "name" the compiler uses is java.lang.Runnable. So even if you duplicate the Runnable interface in your own package, it's not the same as far as the compiler is concerned, because it's in a different package.
    Try importing both java.util.* and java.awt.* (which both have a class or interface named List), and then try to compile List myList = new ArrayList();

  • Syntax Error In Interface Declaration

    Hi,
    while activating proxy i am facing "Syntax Error In Interface Declaration" Error. pls guide me to rectify it.
    Thanks in Advance.
    Regards,
    Chandra

    Hi ,
    XML message interface
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:p1="http://MYTUTORIAL_CM" name="FlightSeatAvailabilityQuery_Out" targetNamespace="http://MYTUTORIAL_CM">
         <wsdl:documentation>
         Flight seat availability query - Out (only for use in XI Demo)
         </wsdl:documentation>
         <wsdl:types>
              <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://MYTUTORIAL_CM" targetNamespace="http://MYTUTORIAL_CM">
                   <xsd:element name="FlightNotFound">
                        <xsd:complexType>
                             <xsd:sequence>
                                  <xsd:element name="standard" type="ExchangeFaultData" />
                             </xsd:sequence>
                        </xsd:complexType>
                   </xsd:element>
                   <xsd:element name="FlightSeatAvailabilityQuery" type="FlightSeatAvailabilityQuery" />
                   <xsd:element name="FlightSeatAvailabilityResponse" type="FlightSeatAvailabilityResponse" />
                   <xsd:complexType name="FlightSeatAvailabilityQuery">
                        <xsd:annotation>
                             <xsd:appinfo source="http://sap.com/xi/TextID">
                             47ad89c013b311dab948000d604e4c90
                             </xsd:appinfo>
                        </xsd:annotation>
                        <xsd:sequence>
                             <xsd:element name="FlightID" type="FlightID">
                                  <xsd:annotation>
                                       <xsd:appinfo source="http://sap.com/xi/TextID">
                                       011d0310139e11da948ef4d509b6dddf
                                       </xsd:appinfo>
                                       <xsd:documentation xml:lang="EN">
                                       Flight ID
                                       </xsd:documentation>
                                  </xsd:annotation>
                             </xsd:element>
                        </xsd:sequence>
                   </xsd:complexType>
                   <xsd:complexType name="ExchangeLogData">
                        <xsd:annotation>
                             <xsd:appinfo source="http://sap.com/xi/TextID">
                             47a65dd013b311dace53000d604e4c90
                             </xsd:appinfo>
                        </xsd:annotation>
                        <xsd:sequence>
                             <xsd:element name="severity" type="xsd:string" minOccurs="0" />
                             <xsd:element name="text" type="xsd:string" />
                             <xsd:element name="url" type="xsd:string" minOccurs="0" />
                             <xsd:element name="id" type="xsd:string" minOccurs="0" />
                        </xsd:sequence>
                   </xsd:complexType>
                   <xsd:complexType name="FlightSeatAvailabilityResponse">
                        <xsd:annotation>
                             <xsd:appinfo source="http://sap.com/xi/TextID">
                             47b970a013b311da8619000d604e4c90
                             </xsd:appinfo>
                        </xsd:annotation>
                        <xsd:sequence>
                             <xsd:element name="EconomyMaxSeats" type="xsd:int">
                                  <xsd:annotation>
                                       <xsd:appinfo source="http://sap.com/xi/TextID">
                                       0b75900013a011daaf1ff4d509b6dddf
                                       </xsd:appinfo>
                                       <xsd:documentation xml:lang="EN">
                                       Maximal Seats Economy Class
                                       </xsd:documentation>
                                  </xsd:annotation>
                             </xsd:element>
                             <xsd:element name="EconomyFreeSeats" type="xsd:int">
                                  <xsd:annotation>
                                       <xsd:appinfo source="http://sap.com/xi/TextID">
                                       0b75900113a011dac95cf4d509b6dddf
                                       </xsd:appinfo>
                                       <xsd:documentation xml:lang="EN">
                                       Free Seats Economy Class
                                       </xsd:documentation>
                                  </xsd:annotation>
                             </xsd:element>
                             <xsd:element name="BusinessMaxSeats" type="xsd:int">
                                  <xsd:annotation>
                                       <xsd:appinfo source="http://sap.com/xi/TextID">
                                       0b75900213a011dacefcf4d509b6dddf
                                       </xsd:appinfo>
                                       <xsd:documentation xml:lang="EN">
                                       Maximal Seats Business Class
                                       </xsd:documentation>
                                  </xsd:annotation>
                             </xsd:element>
                             <xsd:element name="BusinessFreeSeats" type="xsd:int">
                                  <xsd:annotation>
                                       <xsd:appinfo source="http://sap.com/xi/TextID">
                                       0b75900313a011dacc26f4d509b6dddf
                                       </xsd:appinfo>
                                       <xsd:documentation xml:lang="EN">
                                       Free Seats Business Class
                                       </xsd:documentation>
                                  </xsd:annotation>
                             </xsd:element>
                             <xsd:element name="FirstMaxSetas" type="xsd:int">
                                  <xsd:annotation>
                                       <xsd:appinfo source="http://sap.com/xi/TextID">
                                       0b75900413a011da8918f4d509b6dddf
                                       </xsd:appinfo>
                                       <xsd:documentation xml:lang="EN">
                                       Maximal Seats First Class
                                       </xsd:documentation>
                                  </xsd:annotation>
                             </xsd:element>
                             <xsd:element name="FirstFreeSeats" type="xsd:int">
                                  <xsd:annotation>
                                       <xsd:appinfo source="http://sap.com/xi/TextID">
                                       0b75900513a011da9d26f4d509b6dddf
                                       </xsd:appinfo>
                                       <xsd:documentation xml:lang="EN">
                                       Free Seats First Class
                                       </xsd:documentation>
                                  </xsd:annotation>
                             </xsd:element>
                        </xsd:sequence>
                   </xsd:complexType>
                   <xsd:complexType name="FlightID">
                        <xsd:annotation>
                             <xsd:appinfo source="http://sap.com/xi/TextID">
                             47b26bc013b311da99e3000d604e4c90
                             </xsd:appinfo>
                        </xsd:annotation>
                        <xsd:sequence>
                             <xsd:element name="AirlineID">
                                  <xsd:annotation>
                                       <xsd:appinfo source="http://sap.com/xi/TextID">
                                       a099b780139e11da9a55f4d509b6dddf
                                       </xsd:appinfo>
                                       <xsd:documentation xml:lang="EN">
                                       Airline ID
                                       </xsd:documentation>
                                  </xsd:annotation>
                                  <xsd:simpleType>
                                       <xsd:restriction base="xsd:string">
                                            <xsd:maxLength value="3" />
                                       </xsd:restriction>
                                  </xsd:simpleType>
                             </xsd:element>
                             <xsd:element name="ConnectionID">
                                  <xsd:annotation>
                                       <xsd:appinfo source="http://sap.com/xi/TextID">
                                       a099b781139e11da830bf4d509b6dddf
                                       </xsd:appinfo>
                                       <xsd:documentation xml:lang="EN">
                                       Connection ID
                                       </xsd:documentation>
                                  </xsd:annotation>
                                  <xsd:simpleType>
                                       <xsd:restriction base="xsd:string">
                                            <xsd:length value="4" />
                                            <xsd:pattern value="\d+" />
                                       </xsd:restriction>
                                  </xsd:simpleType>
                             </xsd:element>
                             <xsd:element name="FlightDate" type="xsd:date">
                                  <xsd:annotation>
                                       <xsd:appinfo source="http://sap.com/xi/TextID">
                                       a099b782139e11dac6c0f4d509b6dddf
                                       </xsd:appinfo>
                                       <xsd:documentation xml:lang="EN">
                                       Flight Date
                                       </xsd:documentation>
                                  </xsd:annotation>
                             </xsd:element>
                        </xsd:sequence>
                   </xsd:complexType>
                   <xsd:complexType name="ExchangeFaultData">
                        <xsd:annotation>
                             <xsd:appinfo source="http://sap.com/xi/TextID">
                             47a1a2e013b311da8347000d604e4c90
                             </xsd:appinfo>
                        </xsd:annotation>
                        <xsd:sequence>
                             <xsd:element name="faultText" type="xsd:string" />
                             <xsd:element name="faultUrl" type="xsd:string" minOccurs="0" />
                             <xsd:element name="faultDetail" type="ExchangeLogData" minOccurs="0" maxOccurs="unbounded" />
                        </xsd:sequence>
                   </xsd:complexType>
              </xsd:schema>
         </wsdl:types>
         <wsdl:message name="FlightSeatAvailabilityResponse">
              <wsdl:documentation>
              Flight seat availability response (only for use in XI Demo)
              </wsdl:documentation>
              <wsdl:part name="FlightSeatAvailabilityResponse" element="p1:FlightSeatAvailabilityResponse" />
         </wsdl:message>
         <wsdl:message name="FlightSeatAvailabilityQuery">
              <wsdl:documentation>
              Flight seat availability query (only for use in XI Demo)
              </wsdl:documentation>
              <wsdl:part name="FlightSeatAvailabilityQuery" element="p1:FlightSeatAvailabilityQuery" />
         </wsdl:message>
         <wsdl:message name="FlightNotFound">
              <wsdl:documentation>
              Flight not found (only for use in XI Demo)
              </wsdl:documentation>
              <wsdl:part name="FlightNotFound" element="p1:FlightNotFound" />
         </wsdl:message>
         <wsdl:portType name="FlightSeatAvailabilityQuery_Out">
              <wsdl:operation name="FlightSeatAvailabilityQuery_Out">
                   <wsdl:output message="p1:FlightSeatAvailabilityQuery" />
                   <wsdl:input message="p1:FlightSeatAvailabilityResponse" />
                   <wsdl:fault name="FlightNotFound" message="p1:FlightNotFound" />
              </wsdl:operation>
         </wsdl:portType>
         <ifr:properties xmlns:ifr="urn:com-sap:ifr:v2:wsdl">
              <ifr:category>
              ifmmessif
              </ifr:category>
              <ifr:methods>
                   <ifr:method name="FlightSeatAvailabilityQuery_Out">
                        <ifr:isSynchron>
                        true
                        </ifr:isSynchron>
                        <ifr:isInbound>
                        false
                        </ifr:isInbound>
                        <ifr:interfaceCategory>
                        outbound
                        </ifr:interfaceCategory>
                   </ifr:method>
              </ifr:methods>
              <ifr:messages>
                   <ifr:message name="FlightSeatAvailabilityResponse">
                        <ifr:messType>
                        ifmmessage
                        </ifr:messType>
                        <ifr:technicalNamespace>
                        http://MYTUTORIAL_CM
                        </ifr:technicalNamespace>
                   </ifr:message>
                   <ifr:message name="FlightSeatAvailabilityQuery">
                        <ifr:messType>
                        ifmmessage
                        </ifr:messType>
                        <ifr:technicalNamespace>
                        http://MYTUTORIAL_CM
                        </ifr:technicalNamespace>
                   </ifr:message>
                   <ifr:message name="FlightNotFound">
                        <ifr:messType>
                        ifmfaultm
                        </ifr:messType>
                        <ifr:technicalNamespace>
                        http://MYTUTORIAL_CM
                        </ifr:technicalNamespace>
                   </ifr:message>
              </ifr:messages>
         </ifr:properties>
    </wsdl:definitions>
    Regards,
    Chandra

  • Static interface Vs Static nested interface declaration

    Hi,
    I have observed that static interface declaration is not allowed in Java. However static nested interface declaration is allowed.
    I could not understood reason behind this behavior.
    e.g.
    interface A{
         void AA();
         public static abstract interface Aa{
    } ........... this is allowed in Java.
    static interface d{
    } ...... This is not allowed in Java...
    I already know that static mean one for class and interface has only abstract method.
    Please let me know if any one know resign behind this.
    Thanks .

    Why don't you go to a Java forum?

  • Interfaces declare methods that one or more classes may or may not implemen

    Interfaces declare methods that one or more classes may or may not implement.
    true or false?

    Encephalopathic wrote:
    If you want to appear to be more than just someone scrounging for someone else to do their homeworkHe/she is what they is
    [http://forum.java.sun.com/thread.jspa?threadID=5292343]
    [http://forum.java.sun.com/thread.jspa?threadID=5283461]
    [http://forum.java.sun.com/thread.jspa?threadID=5283412]
    [http://forum.java.sun.com/thread.jspa?threadID=5279385]

  • Dynamic interface declaration

    Hello,
    Is it possible to have a dynamic interface declaration like you can have a dynamic object declaration?
    For an object:
    data: lo_object type ref to object.
    create object lo_object type (lv_object_name).
    Is this in some way possible to do with an interface? I need to do this for an interface at runtime.
    Gr,
    Jaron

    You can create data of a dynamically given reference  type (which may be an interface) and move the object reference to it.
    Something like so:
    DATA:
          my_obj TYPE REF TO object,
          lr_data TYPE REF TO data.
      FIELD-SYMBOLS: <fs> TYPE ANY.
      CREATE OBJECT my_obj TYPE my_object_type.
    TRY.
      CREATE DATA lr_data TYPE REF TO (some_interface_type_name).
      ASSIGN lr_data->* TO <fs>.
       <fs> ?= my_obj.
      CATCH cx_sy_move_cast_error.
      CATCH cx_sy_create_data_error.
    ENDTRY.
    Basically, the assignment tests if my_obj is an instance of the type named some_interface_type_name.
    Hope this helps,
    Sebastian

  • How can I know a class which implements Runnable interface has terminated?

    Hello! I have a class which has implements Runnable interface, while I want to execute some operation when the thread has terminate in multithread enviroment.How can I know the thread has terminated?Does it give out some signal?Cant I just call my operation at the end of the run() method?

    I want to execute some operation when
    the thread has terminate in multithread enviroment....
    Cant I just call my operation at the end
    of the run() method?Sure. Before run() ends, invoke that other operation.
    How
    can I know the thread has terminated?Does it give out
    some signal?Not that I'm aware of, but you can do what you described above, or I believe a different object can call isAlive on the thread.

  • Flaw in interface declaration

    Hi,
    While writing a code , i mistakenly compiled the following code with interface declared as :
    interface A extends r
    where r was not declared anywhere
    Anyone can please suggest why this happened. Is this a flaw in JAVA.
    Thanks
    Deepak

    Either you'd mistakenly created a class called "r" earlier, or you were mistaken in thinking that it compiled. Given your apparent predeliction for single letter class names the former seems the most likely.

  • Implementing Runnable interface  Vs  extending Thread class

    hi,
    i've come to know by some people says that Implementing Runnbale interface while creating a thread is better option rather than extending a Thread class. HOw and Why? Can anybody explain.?

    Its the same amount of programming work...
    Sometimes it is not possible to extend Thread, becuase your threaded class might have to extend something else.
    The only difference between implementing Runnable and extending Thread is that by extending Thread, each of your threads has a unique object associated with it, whereas with Runnable, many threads share the same object instance.
    http://developerlife.com/lessons/threadsintro/default.htm#Implementing

  • Why Collection interface declares equals() and hashCode() method

    When I went through the source code of Collection interface, I found equals() and hashCode() are declared? Why? If a class implements this interface, it will inherit these two method from Object, and we can true to override them.

    It's probably so that they can provide the documentation that you see there.

  • Need Clarification reg Runnable interface

    Hi,
    I want to know how can we create a instance of the interface Runnable. I have seen the code running with " new Runnable" in swings. How can we can instantiate the interface. pls clarify if any of you know.
    Thanks,
    Guhan.

    Thanks you very much Hacker.
    _Guhan.                                                                                                                                                                                                                           

  • Have Trouble understanding the runnable interface

    Hi
    I am new to java programming. I have trouble understanding threading concepts.When I run the below code,Thread3 runs first. I need a small clarification here- I created two thread objects
    Thread thread1=new Thread(new RunnableThread(),"thread1");
    Thread thread2=new Thread(new RunnableThread(),"thread2");
    As soon as I create these objects -Will the constructor with the string argument in the "RunnableThread" class gets invoked. If so why doesn't System.out.println(runner.getName()); get invoked for the above objects. what is the sequence of execution for the below program.
    /*************CODE****************************/
    class RunnableThread implements Runnable
         Thread runner;
         public RunnableThread()
         public RunnableThread(String threadName)
              runner=new Thread(this,threadName);          //Create a new Thread.
              System.out.println(runner.getName());
              runner.start();          //Start Thread
         public void run()
              //Display info about this particular Thread
              System.out.println(Thread.currentThread());
    public class RunnableExample
         public static void main(String argv[])
              Thread thread1=new Thread(new RunnableThread(),"thread1");
              Thread thread2=new Thread(new RunnableThread(),"thread2");
              RunnableThread thread3=new RunnableThread("thread3");
              //start the threads
              thread1.start();
              thread2.start();
              try
                   //delay for one second
                   Thread.currentThread().sleep(1000);
              catch (InterruptedException e)
              //Display info about the main thread
              System.out.println(Thread.currentThread());
    }

    srinivasaditya wrote:
    Hi
    I am new to java programming. I have trouble understanding threading concepts.I'd consider it to be an advanced area.
    When I run the below code,Thread3 runs first. I need a small clarification here- I created two thread objects
    Thread thread1=new Thread(new RunnableThread(),"thread1");
    Thread thread2=new Thread(new RunnableThread(),"thread2");No, this is wrong. You don't need your RunnableThread. Runnable and Thread are enough. Your wrapper offers nothing of value.
    >
    As soon as I create these objects -Will the constructor with the string argument in the "RunnableThread" class gets invoked. If so why doesn't System.out.println(runner.getName()); get invoked for the above objects. what is the sequence of execution for the below program.did you run it and see? Whatever happens, that's the truth.
    %

  • Runnable interface

    How start() calls the run(). How run() is defined in the Thread class. How our program's(which implements Runnable) implementation of run() is called while using a Thread object reference variable??

    The run() method in Thread does nothing.
    Each Thread object is associated with a Runnable object, if you don't supply one then it uses itself (Thread implements Runnable). It's best always to supply one for a number of reasons. (You can override the run() method of Thread but that's not good practice).
    When you call start() a new execution context is generated to execute the run() method of the Runnable. That means a new stack for local variables, and a new execution point.
    The old execution context then continues as normal.

  • Using Runnable Interface

    Hi-I'm using the following code to bring up an application(Like a text editor or Internet Explorer) with a file (html or text) as the argument.
    public void run()
        String app = "C:/Program Files/EditPlus 2/editplus.exe";
         String[] callAndArgs = { app, filename };
        String call = app;
        Process child =null;
        try {
        Runtime rt = Runtime.getRuntime();
        if(filename==null) {
        child = rt.exec(call);
        else{
        child = rt.exec(callAndArgs);
        child.waitFor();
        System.out.println("Process exit code is: " + child.exitValue());
        catch(IOException x) {
        System.err.println("IOException starting process!");
        catch(InterruptedException x) {
        System.err.println("Interrupted waiting for process!");
    }This works fine, the passed in file (filename) shows up in EditPlus no problem.
    My question is: Can you bring up the application (EditPlus) inside of a JPanel for example,
    instead of it's own window? Or force it's window into a JPanel?
    Appreciate any help..
    -Reg

    Except for in a very few cases you can't do this
    What are the cases I speak of? Search the web for the JDIC project and poi

  • Problems with interface runnable

    Hi everyone !!,
    I have been developing an application with JDK 1.5.0_06 and applications server Apache Tomcat 1.4.31. It is a multithreaded application which uses a class that implements a runnable interface.
    At the moment, this application must be compiled and executed in another machine with JDK 1.5.0_05. The problem is that when an instance of the interface Runnable is called and its method .start() executed , the instance isnt created and the method run doesn't start.
    I hope you understand what I mean. If you dont , please, ask me.
    Any idea? Any help? I have no idea why this is happening? any problem with the JDK? the applications server?
    Thanks in advance, Mar�a

    problem is that when an instance of the interface
    Runnable is called and its method .start() executed ,
    the instance isnt created and the method run doesn't
    start.
    I hope you understand what I mean. If you dont ,
    please, ask me.
    I don't understand.
    Runnable does not have a start() method.
    What do you mean "the instance isn't created"? If you create an instance of something, it's created. If you don't, it's not.
    If you call a Thread's start() method, that Thread's Runnable's run() method will be executed in a new thread of execution. If you don't, it won't.

Maybe you are looking for