We are using extends thread and implements runnable which class first calli

hi

Yes, the language allows it, but your JSL quote is the 3rd edition, and Java 1.4 is based on the 2nd edition (the 2nd edition of the JSL does not go into such a deep explanation of the example shown, so thanks for that pointer). In any case, since the JSL does not address my specific issue, it is only superficially relevant (IMHO). The language allows it, but the behavior is unpredictable. I think that's what is sticking in my craw. I'm not sure what the behavior should be, but if I had to, I would propose that the behavior should not change when I change the inheritance qualifiers (again, in this particular case), but there may be other considerations.
HibernateUtil is a snippet that can be found in the Hibernate tutorial/reference at [http://www.hibernate.org/hib_docs/v3/reference/en/html/tutorial.html|http://www.hibernate.org/hib_docs/v3/reference/en/html/tutorial.html]
The basic idea is a cached session factory, because session factories are expensive to build. We use multiple databases, so our incarnation of HibernateUtil compares the requested database to the one in a static factory variable. If they match, that factory is used. If they don't match, the thread switches to the requested factory and creates sessions from it.
The odd thing is that with the aforementioned inheritance "typo", it either detects that the requested database is the same as the one in the static factory (which is not true), or it returns the wrong factory (which is wrong). I want to emphasize that no other code changes were made (zero, zip, none, really, I mean it), and lots of other classes extend C1 (from the example) and they have never had this problem.

Similar Messages

  • Extends Thread versus Implements Runnable... difference?

    I've seen them both used and to the naked eye it seems to be pretty much the same (besides the execution).
    Can anyone tell me the major differences between the two methods of multi-threading and how/if one is better?
    Do you ever make a deliberate choice to use Extends over Implements (or vice versa) for a specific task?

    For the record, I've normally used extends Thread, and
    seeing the light that in doing that, I can only extend
    one class, I'm looking into the alternative.
    Are...
    Thread t1 = new Thread(new myRunnableThread());
    Thread t2 = new Thread(new myRunnableThread());
    t1.start();
    t2.start()
    and...
    MyExtendedThread t1 = new MyExtendedThread();
    MyExtendedThread t2 = new MyExtendedThread();
    t1.start();
    t2.start();
    equivalent?
    equivalent meaning that they are equally fast? I'd say no, because in the first example you are creating a thread and a runnable, in the second you are only creating a thread.
    >
    Additionally, consider -
    public class myExtendedThread extends Thread {
    ServerSocket ServiceConnectSocket = new
    ServerSocket(4000);
    NotificationListener mainThread;
    public myExtendedThread(NotificationListener
    _mainThread) {
    mainThread = _mainThread;
    public void run()  {
          while(true)
                 if (ServiceConnectSocket != null)
                     return;
                 try
                     Thread.sleep(5000);
    ServiceConnectSocket = new
    ectSocket = new Socket(host, port);
                     ServiceConnectSocket.close();
                     mainThread.serviceReady();
                 catch (Exception e)
    >
    This thread basically tries to connect to a socket,
    and when it does, it closes the socket it made,
    notifies another thread (passed in at the constructor)
    and returns.
    My question is on what happens when Threads return.
    When this thread returns... what happens exactly?
    What if mainThread.serviceReady restarted that
    t thread? Would it start a NEW thread or just re-run
    the run() of the old one?
    Once a thread returns, how long before Garbage
    Collection will free up the memory it used?
    When the run method returns, the thread is dead. It is not reused automatically. You have to implement some type of thread reuse like my code above.
    I would assume that the normal GC rules apply. Each JVM can decide to cleanup the thread whenever it feels like it.

  • Extends thread and Runnle Interface

    In java there 2 ways to create thread
    1.Extending thread
    2.implements runnable interface
    What is difference between the 2 approaches? which one to use where?

    public class ThreadTest extends Thread {
      public void run() {
      public static void main(String[] args) {
        ThreadTest tt = new ThreadTest();
        tt.start();
    public class ThreadTest extends Runnable {
      public void run() {
      public static void main(String[] args) {
        ThreadTest tt = new ThreadTest();
        Thread t = new Thread(tt);
        t.start();
    }The difference is how you start the thread when you code it. if you extend Thread, you can call its run method directly. When you extends Runnable, A wrapper is needed to start the thread.
    The Runnable approach is used when your class is extending another class (eg. JFrame). Since Java do not support multiple inheritance, you can write something like public class MyProg extends JFrame implements Runnable, and still have a thread.

  • Extends Thread and Remote

    Hi.
    I have a server that creates a Thread to comunicate to other server (a secondary server) using sockets.
    public class Server extends Thread {
    }I need to use RMI now but I can't extend Thread and Remote.
    What can I do?
    Thanks

    Implement the Runnable interface and extend the Remote class. This way you can Construct A thread and pass it an instance of your Runnable interface. ie.
    class MyClass extends Remote implements Runnable{
    // put what ever methods you need and implment the run method
    // for Runnable interface
    now you can do this.
    Thread myThread = new Thread(new MyClass());
    myThread.start(); // to kick it off

  • Should I use a thread and (in this case) how?

    Hi:
    I have a Swing frame (frameA) and on which there is a button; if I double click it,
    it will bring up a second frame (frameB). On frameB, I will select a new button name
    from a combobox, and click "DONE" button, and frameB would change the name of the
    button on frameA to this new name I selected. And frameB would disappear as well.
    I am thinking of using another thread for painting frameB, because I don't know how long
    it would take for frameB to load up, and I don't want to block up the event-dispatching thread
    on frameA.
    However, since frameB uses another thread, and frameB also has an ActionListener
    associated with the DONE button, i am not sure how to make the thread stay alive
    so that it could check whether the ActionEvent is fired. So, in this case, is it necessary to use
    another thread to do the job? Or should I just use the same event-dispatching thread?
    Or is there another whole new approach much better?
    Thanks

    Quite simply, I wouldn't bother threading it.
    If you load, link and instantiate the pop-up frame (actually I'd use a Dialog here) before you trigger the pop-up, the reaction is more or less instant. The execution of th parent frame will continue after the pop-up has been made visible, so any way you cut it, you are going to get a brief pause in the parent UI while the pop-up is shown - you may as well have it when the button is clicked.
    Hope this helps.--
    <sig> http://www.itswalky.com http://www.crfh.net </sig>

  • I have firefox 7 and still get warnings "You are using an old version of Firefox which Gmail no longer supports or Google Plus incompatible. How can I fix?

    When I tried to join Google Plus I get the message Browser no longer supported. First Happened when using firefox 6.0.2 and still happens now with FF 7.
    Also Gmail shows "You are using an old version of Firefox which Gmail no longer supports. Some features may not work correctly"
    and at the bottom of this page the "educated guess" about my browser shows 3.0.15

    Your about:config has been modified with the lines
    general.useragent.extra.microsoftdotnet
    ( .NET CLR 3.5.30729)
    general.useragent.override
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.15; .NET CLR 2.0.50727; ffco7) Gecko/2009101601 Firefox/3.0.15 …
    That is why Google is reporting old version.
    You need to ether find out why or create a new profiles and see if this line is gone. [[Profiles]]
    There is some verbose about MS, but I don't know of any MS add-on that would do this.

  • I upgraded to 6.02 and still get this message from Gmail: "You are using an old version of Firefox which Gmail no longer supports. Some features may not work correctly. Upgrade to new version."

    When I opened Gmail in my Firefox browser, I got a message I've never seen, before: "You are using an old version of Firefox which Gmail no longer supports. Some features may not work correctly. Upgrade to new version." I clicked on upgrade to a new version and was taken to the Mozilla site, where I downloaded the latest version of Firefox... then, when I restarted my computer, Gmail still gives me the same message!! What's going on?

    Firefox 4 and later require at least OS X 10.5 and a Mac with an Intel processor.
    *http://www.mozilla.org/firefox/12.0/system-requirements/
    For an unofficial Firefox ESR 10.0.4 compatible version (TenFourFox) that runs on PowerPC Macs with OS X 10.4.11 or OS X 10.5.8 you can look at:
    *http://www.floodgap.com/software/tenfourfox/
    *http://www.macupdate.com/app/mac/37761/tenfourfox
    Be aware that TenFourFox doesn't support plugins.
    *http://code.google.com/p/tenfourfox/wiki/ReleaseNotes1004
    *http://code.google.com/p/tenfourfox/wiki/PluginsNoLongerSupported
    *http://code.google.com/p/tenfourfox/wiki/AAATheFAQ

  • I want ro remove all of the default Firefox bookmarks. There are way too many and none of which are usefull to me. I would like to make my old IE Favorites folder the default. How can I do this?

    I need to remove the default Firefox bookmarks.
    There are way too many and none of which are usefull to me.
    Also, I am vision impaired and reading through such a long list is very eye-fatigueing to me.
    I would like to make my old IE Favorites folder the default. How can I do this?

    Did you import an iPhoto Library from the old Hard Drive? Do you still have that old Library?
    The way to clear out a Library is to Export the photos - Apps like iPhoto2Disk or PhotoShare will help you export to a Folder tree matching your Events.
    For the annoying start-up message:
    Go to your Pictures Folder and find the iPhoto Library there. Right (or Control-) Click on the icon and select 'Show Package Contents'. A finder window will open with the Library exposed.
    Look there for a Folder called 'Import' or 'Importing'.
    Drag it to the Desktop. *Make no other changes*.
    Start iPhoto. Does that help?
    If it does then look inside that folder on your desktop. Does it contain anything you want? If not you can trash the folder.

  • HT4946 by mistake my contacts are deleted from iphone and the pc which itunes installed is corrupted, i have the itunes backup folder,is this possible to restore the contacts from my old itunes backup folder to iphone!?

    by mistake my contacts are deleted from iphone and the pc which itunes installed is corrupted, i have the itunes backup folder,is this possible to restore the contacts from my old itunes backup folder to iphone!?

    unless you had them synced with icloud or some other email account, very unlikely

  • How to use multiple threads and swing for displaying status/interaction

    I have a Swing-app which have to show progress and allow userinteraction for these tasks:
    * First:
    retrieve a list of IDs(String) from the database (single thread running)
    * Second:
    some work on the id-list and list written to hd (same thread as above)
    * Third:
    retrieve Objects (based on the id-list) from different sources (Multiple Threads are running)
    To show the status I have a JProgressBar (indeterminate while task1&2 running) and
    a JTextArea showing the current status (connect,retrieve list, sort, ...)
    When task3 is starting the JTextArea have to disappear and be replaced by a ScrollPane
    with an array of Labels/TextAreas showing the status of each thread.
    While theses threads are working, the ID-list will be consumed and the JProgressBar
    shows the remaining precentage of the hole progress.
    Everything is working so far (excepts UI :) , the problem(s) I have:
    I need the threads to interacts with the user through the ui. e.g: "Connection to db-xyz lost! reconnect?"
    But I don&#180;t know how to do this correctly.
    I think one way would be to send an event to the ui... but how?
    (the ui must know which thread is calling to unpause it after user answered)
    I know that threads should NOT change the swing(-container) - How do I notify the ui that a thread has a question?
    Since these threads are really time-consuming the UI is not updated frequently,
    how can I increase this? (perhaps using another thread-priority?)
    thanks for help!

    if/when your threads need to interact with the UI, they can create a Runnable & send it to SwingUtilities.invokeLater or invokeAndWait. This Runnable can popup a message to the user, and act on the choice of the user (reconnect, cancel, ...). This action could be something which "unpauses" the task thread.
    You may need to do synchronisation between the code in the Runnable & the Thread to which it is related - so the latter Thread knows when the user has made the choice.

  • Extending JEditorPane And Implementing Custom Attributes

    I was experimenting with the following code :
    class MyEditorPane extends JEditorPane
         private String str="";
         private boolean status=false;
         MyEditorPane(String str, boolean value)
              this.str=str;
              this.status=value;
         public String getString()
              return this.str;
         public boolean getStatus()
              return this.status;
    }now I wanted to instantiate this class and then get the values by calling the get methods in the following manner :
    MyEditorPane editor=new MyEditorPane("hii...",true);
    System.out.println(editor.getString());
    System.out.println(editor.getStatus());but the problem is that the instance *'editor'* doesn't seem to identify those two manually coded methods..........
    can anyone please enlighten me as to what I have done wrong and is there any other way of implementing this concept of having my own attributes attached with a java component?
    awaiting ur response.......

    Are you getting a compile error? Or a runtime problem?
    Are you sure that the MyEditorPane in the accessing code is the same MyEditorPane as in your example?
    This works fine for me:
    import javax.swing.JEditorPane;
    class MyEditorPane extends JEditorPane {
        private String str = "";
        private boolean status = false;
        MyEditorPane(String str, boolean value) {
         this.str = str;
         this.status = value;
        public String getString() {
         return this.str;
        public boolean getStatus() {
         return this.status;
        public static void main(String[] args) {
         MyEditorPane editor = new MyEditorPane("hii...", true);
         System.out.println(editor.getString());
         System.out.println(editor.getStatus());
    }Piet

  • How to identify the SQLs which are using the tables and new columns

    Hi
    I m using oracle 10G Database in windows. Developers have added some columns in some of the database tables and were asking to check whether there is some impact on performance or not. I have not done this performance tuning before. Kindly help me how to proceed further.
    How to obtain the sqls which are touching the tables and the new columns? It would be really great if you can help me with this.
    Thanks

    You can try to use DBA_DEPENDENCIES to get PL/SQL objects using tables: http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_1041.htm#i1576452.
    However if SQL code is not stored in database in a trigger, a procedure, a function, a package or a view, it is impossible to retrieve all SQL code referencing some table from database dictionary: for this you would have to analyze application source code.

  • Some materials are used by WM and some materials are not used by WM in SLOC

    Dear Experts.
    We are going to use WM in F100 Storage Location.
    But because of business, Some materials(A) will be managed by WM and some materials(B) will be not managed by WM in same storage location.
    So some materials(A) have WM view in material master and some materials(B) have no WM view.
    But when posting GR for material(B), error occurs.
    the message is as below.
    Material 6850009 does not exist in warehouse F01
    Message no. L9023
    Diagnosis
    All the materials that you use within a warehouse number must also be defined for this warehouse number.  The material you are using is not defined.
    Procedure
    If you want to use the material within your warehouse number, you must create the material in the material segment for that warehouse number.
    Let me know how to fix it.
    We are going to use WM in A sloc.
    In A Sloc, some material are managed by WM level and some material are managed by only MM level.
    Thank you in advance.
    Best reagrds,
    Kil-Nam

    You assign a warehouse to a storage location, which means that the entire storage location is warehouse managed. all materials in this storage location have to have a WM view,
    It is not possible to decide it on material level if it is subject to WM or not.
    You have to create an extra storage location for the non-WM-materials  to meet your requirement

  • Very Basic Question on Threads and Object Manipulation between classes

    I have a feeling this is on the virge of being a stupid question but hey, its the right forum.
    Lets assume I have a class that extends Jframe : Jframe1
    In that frame there is only one Jlabel : Jlabel1
    I want to create a thread that will affect Jlabel1
    The thread will run an endless loop that will.. for example change the color of the label to a random color and then the thread will sleep for a given time. There is no use in this program. Its only meant to help me understand
    I have looked up info and examples on threads. Unfortunately none were useful. Most examples try to illustrate the use of threads with the example of an applet digital clock. But it does not help with my problem, not to mention I dont want to delve into applets at this time.
    I know I have to make a class that extends thread. Does it have to be an inner class?
    How do I get to affect the frame's Jlabel1 from it? It says it doesn't know anything about it.

    import javax.swing.*;
    import java.awt.*;
    import java.util.*;
    public class Jframe1 extends JFrame implements Runnable{
      Container con;
      JLabel Jlabel1;
      Random rand;
      Color c;
      public Jframe1(){
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        con = getContentPane();
        rand = new Random();
        Jlabel1 = new JLabel("bspus", JLabel.CENTER);
        Jlabel1.setOpaque(true);
        con.add(Jlabel1, BorderLayout.NORTH);
        setSize(300, 300);
        setVisible(true);
      public void run(){
        while (true){
          try{
            Thread.sleep(1000);
          catch (InterruptedException e){
            break;
          int n = rand.nextInt(16777216);
          c = new Color(n);
          SwingUtilities.invokeLater(new Runnable(){
            public void run(){
              Jlabel1.setBackground(c);
      public static void main(String[] args){
        Jframe1 jf = new Jframe1();
        new Thread(jf).start(); // you don't need to create a new thread
      }                         // because this Main thread is just
                                // another thread.
                                // here, only for demonstration purpose,
    }                           // we make a new separate thread.

  • Why are my Macbook Pro and my iPad able to place calls, but not receive them?

    I have a MacBook Pro late 2013 edition and last year's iPad Air as well as the iPhone 5s.  I have all of my devices completely signed in to my iCloud account and all of the appropriate boxes checked.  I can place calls using my iPad and my computer, but when my phone rings, it doesn't ring on either the iPad or my computer.  Strangely enough, my iPad used to receive phone calls a month ago, before most of this all came into play, but as already stated, it now does not.  All of my devices are updated to the latest software and I can seamlessly utilize all other handoff features between all three devices. 
    Any help or advice is greatly appreciated!

    Hi, MrsRhiMac.  
    Thank you for visiting Apple Support Communities.  
    Here is an article that I would recommend taking a look at when experiencing this issue.  
    Get help using Continuity with iOS 8 and OS X Yosemite
    http://support.apple.com/kb/TS5458
    Cheers, 
    Jason H.

Maybe you are looking for

  • Assigning BW Reports to Roles

    Hi, I have 200 BW Reports that I need to Assign to 13 Roles. At present the only way I can think of doing it is by trawling through each query one-by-one and publishing to the role from Query Designer. Can someone tell me if there is a much quicker w

  • Thought of functional consultant Vs abap

    Dear All, I am techno functional consultant. I thought and very funny sometimes, but its bad habit to laugh on anyone. Thought of Functional consultant: I have requirement of  report X in which when user create PO--->make GR> take print then it shoul

  • Infoobject used in Lookups

    Hi All, I have an infoobject. I want to know where is it used as a Look Up (in update rules). How can I find the list? Pls. help. Thanks In Advance

  • After updating CC apps on 7/19, almost none of my fonts display

    After updating all of my Creative Cloud apps the other day, all of my documents are in shambles. Most fonts I use won't display properly. Everything still displays properly on another machine running CS5.5, but it is not an option for me to use that

  • How come pc's get viruses and not macs?

    i'm thinking of either getting a macbook or macbook pro, and moving away form PC (finallllyyyyy!!). and i was just wandering if someone could tell me how macs don't seem to get viruses (as apple claims) and PCs do. also what software does mac use for