Different output for each running (Thread & Runnable)

When i run a program which extends Thread or implement Runnable interface, i get different output each time i run from either of the program. Why this can happen? Why the output from the program which extends Thread different from the output which implementing Runnable? i really can't figure out..can someone explain it to me?? thank you!!
regards,
san san

Please be a little more explicit about what you're doing, what you expect to happen, and what you actually observe.
Please post a short, concise, executable example of what you're trying to do. This does not have to be the actual code you are using. Write a small example that demonstrates your intent, and only that. Wrap the code in a class and give it a main method that runs it - if we can just copy and paste the code into a text file, compile it and run it without any changes, then we can be sure that we haven't made incorrect assumptions about how you are using it.
Post your code between [code] and [/code] tags as described in Formatting Help on the message entry page. Cut and paste the code, rather than re-typing it (re-typing often introduces subtle errors that make your problem difficult to troubleshoot). Please preview your post when posting code.
Please assume that we only have the core API. We have no idea what SomeCustomClass is, and neither does our collective compiler.
If you have an error message, post the exact, complete error along with a full stack trace, if possible. Make sure you're not swallowing any Exceptions.

Similar Messages

  • Different output for each running(Thread or Runnable)

    When i run a program which extends Thread or implement Runnable interface, i get different output each time i run from either of the program. Why this can happen? Why the output from the program which extends Thread different from the output which implementing Runnable? i really can't figure out..can someone explain it to me?? thank you!! Belows are the program im trying to run..
    <code>
    public class RunThreads
         public static void main (String [] args)
              SomeThread p1 = new SomeThread(1);
              p1.start();
              SomeThread p2 = new SomeThread(2);
              p2.start();
              SomeThread p3 = new SomeThread(3);
              p3.start();
    } //end class RunThreads
    public class SomeThread extends Thread
         int myID;
         SomeThread(int id)
              this.myID = id;
         public void run()
              int i;
              for(i=1;i<11;i++)
              System.out.println("Thread" + myID + ": " + i);
    } //end class SomeThread
    </code>
    <code>
    public class RunThreads2
         public static void main (String [] args)
              Thread p1 = new Thread(new SomeThread2(1));
              p1.start();
              Thread p2 = new Thread(new SomeThread2(2));
              p2.start();
              Thread p3 = new Thread(new SomeThread2(3));
              p3.start();
    } //end class RunThreads2
    public class SomeThread2 implements Runnable
         int myID;
         SomeThread2(int id)
              this.myID = id;
         public void run()
              int i;
              for(i=1;i<11;i++)
              System.out.println("Thread" + myID + ": " + i);
    } //end class SomeThread2
    </code>

    Umm, could you explain the differences in the output first?

  • Java-puzzlers...Why 2 different outputs for the same line

    Here, why it is giving 2 different outputs for the same set of lines
    Line-1 and Line-2 are both same.But giving 2 different results ???
    /*java-puzzlers*/
    public class Elementary {
        public static void main(String[] args) {
             System.out.println(12345 + 5432l);  /*Line-1: Original statement- didn't modify*/
          System.out.println(12345 + 54321);  /*Line-2: I wrote - I delete 12345 + 54321 and wrote the same thing again*/
    }

    kjshikal wrote:
    one of them is a longkjshikal,
    For the third and final time. Please stop resurrecting old threads like this.
    Thank you for your co-operation.

  • Different BOM for each month

    Hi,
    The BOM is different for each month. If i make different alternatives for each month and run the LTP will it help to get the raw material requirement as per the BOM for that month. Example BOM for NOV/DEC will be not same but we want to estimate the raw material req for next year.
    Kindly advise what i need to do?
    Regards
    ShankarR

    Dear Shankar,
    1.What is the business contraint in using change number functionality to address this requirement without creating any
    additional alternative BOM?
    2.Say you create the first alternative BOM using a change number and save all the BOM components.
    3.The default valid from date will be the valid from date of the change number and valid to date will be 31.12.9999.
    4.Whenever there is a BOM change use a different change number with valid from date say 25.10.2010,so using this in the
    same BOM delete the components and add the new component's or make any BOM change and save.
    5.For the deleted components the valid from date will be say (you have created using today's date for BOM creation)
    05.10.2010 and the valid to date will be 25.10.2010.
    6.What is the advantage of creating new alternative BOM?
    6.How are you using the LTP results for inventory purpose,say how are you planning the raw material's requirement for the
    next year based on this year's BOM?
    7.LTP is not only the feasibility of material procurement,but also production that can be produced with available resource.
    Check and revert
    Regards
    S Mangalraj

  • How to acquire from various AI channels simultaneously with a different range for each one?

    How to acquire from various AI channels simultaneously with a different range for each one?
    In LabView I have found some examples but in C there isn't seem to be any.
    Solved!
    Go to Solution.

    Or you can add channels one by one with individual instructions: the follwing code compile and runs with no errors on a vitual daq device:
    err = DAQmxCreateTask ("", &taskH);
    err = DAQmxCreateAIVoltageChan (taskH, "Dev1/ai0", "AI0", DAQmx_Val_Cfg_Default, -5.0, 5.0, DAQmx_Val_Volts, "");
    err = DAQmxCreateAIVoltageChan (taskH, "Dev1/ai1", "AI1", DAQmx_Val_Cfg_Default, -10.0, 10.0, DAQmx_Val_Volts, "");
    DAQmxStartTask (taskH);
    err = DAQmxReadAnalogF64 (taskH, 5, 10.0, DAQmx_Val_GroupByChannel, val, 10, &read, 0);
    DAQmxClearTask (taskH);
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • I have 3 iphones, an ipod touch and an Ipad on the same itunes account.  should I have a different account for each device?  If so how do I get all my purchases, like music on all the devices?

    I have 3 iphones, an ipod touch and an Ipad on the same itunes account.  should I have a different account for each device?  If so how do I get all my purchases, like music on all the devices?

    You can sync as many devices as you want to the same iTunes account, there is no limit. You can have the same content on each device or different content, the choice is yours. iTunes will keep everything straight, by device, including separate backups. I'd suggest giving each device a unique name, to make things easier.

  • I have multiple emails, how do I add different signatures for each email address

    I have multiple emails for different companies I work for, how do I add a different signature for each one, it seems like I have to use the same one for all of them

    Thanks.  I think I'm on the right track.  I added the email address to my contacts and double clicked the image icon to change it, but it only lets me snap a new picture or select an image from another location.  What is the folder location of the stock icons that come with Mac OSX?

  • How to use the different class for each screen as well as function.

    Hi Experts,
    How to use the different class for each screen as well as function.
    With BestRegards,
    M.Thippa Reddy.

    Hi ThippaReddy,
    see this sample code
    Public Class ClsMenInBlack
    #Region "Declarations"
        'Class objects
        'UI and Di objects
        Dim objForm As SAPbouiCOM.Form
        'Variables
        Dim strQuery As String
    #End Region
    #Region "Methods"
        Private Function GeRate() As Double
                Return Double
        End Function
    #End Region
    Public Sub SBO_Appln_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean)
            If pVal.BeforeAction = True Then
                If pVal.MenuUID = "ENV_Menu_MIB" Then
                End If
            Else ' Before Action False
                End If
        End Sub
    #End Region
    End Class
    End Class
    Rgds
    Micheal
    Vasu Anna Regional Feeling a???? Just Kidding
    Edited by: micheal willis on Jul 27, 2009 5:49 PM
    Edited by: micheal willis on Jul 27, 2009 5:50 PM

  • How to configure different listener for each database in 11gR2 RAC

    Hi Friends,
    Current Prod Setup :
    11gR2 (11.2..0.2) RAC on RHEL 5.5 with 3 SCAN Listeners on default 1521 port.
    Having 4 databases which are using SCAN-IP and listening on default port only.
    As per policy, we have to create separate listeners (on different port) for each database.
    like,
    DB1 - 1522
    DB2 - 1523
    DB3 - 1524
    DB4 - 1525
    Even If I configure 4 listeners using NETCA, how my failover & load balancing will happen using SCAN & Newly Created Listeners ???
    Thanks in advance..
    Regards,
    Manish

    Hi,
    I tried on 11gR2 TEST RAC Server to have different listener with different port (1529) for SCAN & Node Listener & tested failover, load-balancing which was successful.
    [oracle@ravish5 admin]$ cat listener.ora
    LISTENER_A=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_A)))) # line added by Agent
    ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_A=ON # line added by Agent
    [oracle@ravish5 admin]$ ps -ef | grep lsnr
    oracle 1985 1 0 00:46 ? 00:00:00 /11g_crs/11.2.0.2/product/home/bin/tnslsnr LISTENER -inherit
    oracle 1988 1 0 00:46 ? 00:00:00 /11g_database/11.2.0.2/product/home_1/bin/tnslsnr LISTENER_A -inherit
    oracle 2928 1 0 01:00 ? 00:00:00 /11g_crs/11.2.0.2/product/home/bin/tnslsnr LISTENER_SCAN1 -inherit
    [oracle@ravish5 admin]$ lsnrctl status LISTENER_A
    LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 02-MAY-2012 03:19:35
    Copyright (c) 1991, 2010, Oracle. All rights reserved.
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_A)))
    STATUS of the LISTENER
    Alias LISTENER_A
    Version TNSLSNR for Linux: Version 11.2.0.2.0 - Production
    Start Date 02-MAY-2012 00:46:42
    Uptime 0 days 2 hr. 32 min. 54 sec
    Trace Level off
    Security ON: Local OS Authentication
    SNMP OFF
    Listener Parameter File /11g_database/11.2.0.2/product/home_1/network/admin/listener.ora
    Listener Log File /11g_database/11.2.0.2/diag/tnslsnr/ravish5/listener_a/alert/log.xml
    Listening Endpoints Summary...
    (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_A)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.3.5)(PORT=1529)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.3.16)(PORT=1529)))
    Services Summary...
    Service "TEST" has 1 instance(s).
    Instance "TEST2", status READY, has 1 handler(s) for this service...
    Service "TESTXDB" has 1 instance(s).
    Instance "TEST2", status READY, has 1 handler(s) for this service...
    Service "srvc_test.clover.com" has 1 instance(s).
    Instance "TEST2", status READY, has 1 handler(s) for this service...
    The command completed successfully
    SQL> show parameter listen
    NAME TYPE VALUE
    listener_networks string
    local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD
    DRESS=(PROTOCOL=TCP)(HOST=192.
    168.3.16)(PORT=1529))))
    remote_listener string ravish-scan:1529
    SQL> exit
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
    Data Mining and Real Application Testing options
    [oracle@ravish5 admin]$ srvctl config scan_listener
    SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521,1529
    [oracle@ravish5 admin]$ srvctl config scan
    SCAN name: ravish-scan, Network: 1/192.168.3.0/255.255.255.0/eth0
    SCAN VIP name: scan1, IP: /ravish-scan.clover.com/192.168.3.22
    [oracle@ravish5 admin]$ srvctl config listener
    Name: LISTENER
    Network: 1, Owner: oracle
    Home: <CRS home>
    End points: TCP:1521
    Name: LISTENER_A
    Network: 1, Owner: oracle
    Home: /11g_database/11.2.0.2/product/home_1
    End points: TCP:1529
    [oracle@ravish5 admin]$ srvctl config service -d TEST -s srvc_test.clover.com
    Service name: srvc_test.clover.com
    Service is enabled
    Server pool: TEST_srvc_test.clover.com
    Cardinality: 2
    Disconnect: false
    Service role: PRIMARY
    Management policy: AUTOMATIC
    DTP transaction: false
    AQ HA notifications: true
    Failover type: SELECT
    Failover method: BASIC
    TAF failover retries: 0
    TAF failover delay: 0
    Connection Load Balancing Goal: LONG
    Runtime Load Balancing Goal: NONE
    TAF policy specification: BASIC
    Edition:
    Preferred instances: TEST1,TEST2
    Available instances:
    TEST_NEW =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ravish-scan.clover.com)(PORT = 1529))
    (LOAD_BALANCE = yes)
    (FAILOVER = ON)
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = srvc_test.clover.com)
    (FAILOVER_MODE =
    (TYPE = SELECT)
    (METHOD = BASIC)
    Actually different ports for different databases are required to have separation of duties. Once Firewall enabled betwen Client & DB Server only privileged users would have access to particular database.
    Regards,
    Manish

  • How to set up different realms for each server ?

    I am using weblogic 6 sp1.I have a domain with several servers. i want to assoicate or use different custom security realm for each server.However -on weblogic console- there is no 'Target' tab in the Security node ,and no way to set up multiple Security nodes.How ca i do this (or can i)?

    Main reason why is this:
    Imagine situation I have 2 servers A and B both of them bellongs to domain SomeDomain.
    Server A is as WebServer and server B hosts all EJBs. And server A is outside
    firewall (does not have DB access). But i would like to use RDBMS realm so what
    to do in this situation. Place both servers in different domains and in server
    A install proxy realm for RDBS realm ?
    "Tom Moreau" <[email protected]> wrote:
    >
    You can't have a different realm for each
    server. There is only one realm for all
    servers - think of it as there is only
    one set of authentication & authorization
    information (that is users/groups/permissions)
    and it applies to all servers.
    Why do you want each server to have its
    own realm? If someone tries to log in,
    do you want WLS to automatically route
    them to a server who is capable of logging
    them in? I'm having trouble understanding
    why you want this feature.
    Thanks,
    -Tom Moreau
    Rachel <[email protected]> wrote:
    I am using weblogic 6 sp1.I have a domain with several servers. i want
    to assoicate or use different custom security realm for each server.However
    -on weblogic console- there is no 'Target' tab in the Security node
    ,and no way to set up multiple Security nodes.How ca i do this (or can
    i)?

  • Qry:How to get different price for each price list (variable area) in order

    1-How to get different price for each price list (variable area) in order for sale. for the opportunity to display and select multiple prices.
    2- I add a location store from a table in line item and I want to see this area in order,.
    I 'm created 2 field location(item line and order), 1 table location
    I tried this for exemple : select $ [userfieldlocation.OITW]

    Thanks Suda for your answer,
    the Formatted Search for prices is OK, but for the Item locations in warehouse this is not so simple,     
    I must have several (at least 2) locations for the item in the Warehouse and a track of this location and search possibilities.
    read carefully and imagine how (Management warehouse locations)
    I added a user table '@Location' who linked to a user field 'U_Location in Item master data --> lnventory data  line and an ather user field 'U_Location' in sales order
    I met the value of location in the table (list of locations for any warehouse), I select the location of each item while receiving merchandise in the user field of inventory data line (Item M data) and this value appears in the sales order 'U_Location' user field ( only the location value in the default warehouse for this Item)
    or
    create an user field 'location' in Good receipt PO to fill it while receiving merchandise that appears in the sales order to give possibility to find/select the location of the item at this order and in Item master data
    I think we will use all these tables
    @LOCATION
    PDN1
    OITM
    OITW
    OWHS
    RDR1
    Juste a another question : where you found this and What is: ' 38.1.0 '
    Is it in document (System information):Item=38 Pane=1 ??
    Thanks,
    Ouchen

  • Different chart for each level hierarchy in report designer

    Is there a way to display a different chart for each level of the hierarchy in a report designer? I want a different chart for each level. That is, if there are 5 nodes in level 4, I want 5 different nodes. Is there a way to do this? I tried to insert the chart inside a cell in each level, but it shows the same chart for all nodes instead of a different chart for each node.

    Has any one tried using a context sensitive chart?  According to this, it seems like this should be possible, but I am having no luck.
    http://help.sap.com/saphelp_nw70/helpdata/en/47/a99a0a5fdb0985e10000000a42189c/frameset.htm

  • Different caption for each photo in web gallery

    When you take your selected Photos from Library  to WEB is it possible to have a different caption for each photo. If I select 1 photo from the import and change its caption using the caption popup in the "Image Info" pane all the image captions change even the unselected ones.
    How can I change individual photos so that they will have individual captions in the web gallery?

    You should change the caption metadata field in the Library module. Go to the Library module, select the image you want to change the caption on, in the right panel, scroll down to the metadata section. Make sure that the popup to the left of metadata is set to "default" and you should see the standard metadata. Simply type your caption here. Then, if you've done this for all your photos, go back to your web section and make sure you set the caption popup in the image info section back to "caption", which will use the info in the caption metadata field for each photo automatically.

  • Drop Down List in a table - different options for each row

    How can i have a drop down list in a table with different options for each row?
    My requirement is this.. I want to display, say employee dtails in a table, and one column is employee hobbies, whcih can have multiple values and each employee may have a different list of hobbies. So how can we populate the drop down for each row, with different options?

    Hey. Uh, this probably isn't the answer you were looking for, but it sounds like you've got a problem with your database design there. Generally speaking, your tables shouldn't have multi-valued fields, in the relational model anyway (sql). Instead, you should look at adding a separate table like EMPLOYEE_HOBBIES. Then you have a foreign key using the employees primary key as the foreign key in the employee_hobbies table, see what I mean? I might have misunderstood your explanation though, I'm not sure.
    Alternatively, you could just have hobbies as a big freeform varchar field, and don't bother to make people separate their hobbies into different fields (you'd have to abandon the drop-down listbox idea in this case). If there's no really important reason to make the distinction, then it's probably easier just to not do it.

  • Different formats for each line in enums & rings?

    I don't know if this one is possible but I can't figure it out.
    Can you make an enum or ring control have a different format for each selection? 
    E.G.:
    Selection 1 [default]
    Selection 2 [test mode]
    Selection 3 [optional]
    Selection 4 [optional]
    I've tried the formatting options and property nodes, no luck.  Maybe there are possibilities with control customizing I'm not thinking of???
    Thanks & Regards,
    K
    Using LabVIEW: 7.1.1, 8.5.1 & 2013

    Hi K.
          I don't think it's possible to have those text properties vary in a text-ring, but you might be able to accomplish your goal using a pict-ring - using images of formatted text.  In the example (attached) Paint was used to create the pictures then import them into the pict-ring.  Here Unclebump shows how to use "Draw Text at Point.vi" to create formatted text in a picture control, though, I have no idea how to copy such pictures out of the pictures control!
    Cheers!
    "Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
    Attachments:
    FormattedTextPicRing.vi ‏14 KB

Maybe you are looking for

  • DEP stops Itunes From Working Help plz

    I just got 2 new ipods and cant even use them my sisters Itunes works on her computer we got Same OS (Vista) and I try many ways of trying of fixing it and checked online I cant find anything and my sister in Collage so I can use her computer

  • Import Transaction Data - Duplicate records

    Hi, I need to upload a file of transaction data into BPC using data manager package. I've done the transformation and conversion files which validate successfully on a small data set. When I try to upload the data file using the real life file, it fa

  • Composite with dependency not working after soa server restart

    Hello, I have composite application that invokes another composite application. After deploying those work fine. But after restarting soa server the one having dependency does not work any more. To soa server log I get following: <Jul 1, 2010 11:45:2

  • Rmi connector to add MBean

    Hi,all i have some trouble to add mbean i connect agent with rmi connector Here is my code this is my agent public class MyAgent {      //MBean server private MBeanServer mbeanServer ; public MyAgent() {      //create mbean server      mbeanServer =

  • Ipfw in Leopard 10.5.2

    I don't get it, it just doesn't work with GUI in System Preferences--Security-Firewall. So, everyone should be at least unix sys admin. Please give it back all Firewall settings in GUI that MacOS X 10.4 had. You made 10.5 firewall GUI is easy but it'