'PUBLIC' thread vs 'PRIVATE' thread in v$thread

Hi all,
Our db is 10g RAC db and the servers are 2003 MS window. Can anybody tell me what the differences are between a thread is 'PUBLIC' and a thread is 'PRIVATE'?
Thank you so much for your help!!
Shirley

A "PUBLIC" thread can be acquired by any instance at startup.
This has nothing to do with Transaction Load Balancing. Your ArchiveLog volumes
indicate that one instance has more transactions (Redo generation) then the
other. Either the application / clients are statically configured to run more
transactions on one instance then the other OR round-robin Load Balancing
isn't effective in that heavier transaction loads happen to be occurring on one
instance.
Sometimes it makes sense for one instance to be busier than the other.
a) When the servers are not equally configured (eg different CPU counts)
b) When a certain part of the application / schema is more heavily used
and that application statically uses one instance so as to avoid block pinging
across the instances.

Similar Messages

  • Public APIs vs Private APIs

    Hi All,
    Am a beginner in Apps want to know whts the difference between Public APIs and Private APIs
    rgds

    Yes class-dump can always be used to generate public interfaces in a hostile world but that's not really the point. The issue is how to generate clean interfaces for a team of software developers. Anyway after talking to Matt, I have answered my own question: a synthetic property, a category plus a hand coded setter will make this work. Once the bug in @synthesize is fixed this will be nice solution to the problem.
    Here are a few bits to illustrate:
    In MyClass.h
    @interface MyClass
    @property (readonly) id someProperty;
    @end
    In MyClass.m
    #import "MyClass.h"
    @interface MyClass (Private)
    @property (retain) id someProperty;
    @end
    @implementation MyClass
    @synthesize someProperty;
    // Bug - hand written setter needed since @synthesize will not generate one for me
    - (void) setSomeProperty: (id)newProperty
    if (newProperty != someProperty)
    [someProperty release];
    someProperty = [newProperty retain];
    @end
    Files that import MyClass.h will only have access to the getter while the setter is available to MyClass.m.

  • Public sector Vs private sector

    Hi,
    Could any one please let me know the differences in public sector and private sector.

    Hi,
    Question is not very clear. but i will try to explain from SAP angle
    In SAP perspective, in Public sector funds Budget and budget monitoring is very important.
    Use of Funds management module is more for Public sector . Everything will be earmarked and it is not allowed to cross the earmarked funds(basically budget figures)
    Private sector concentrates more on profitablity and is flexible
    It is difficult to implement in Public sector compared to Proivate sector
    Assign points if useful
    Sunoj

  • Calendar apps:  1. That my wife and I can share.  2. That shows some of the text in the full month view.  3.  That can have "public" events and "private" events.

    Hello All,
    I am looking for a calendar app that my wife and I can share on both of our iphones.  I am new to this and haven't found an app that will do what I want.
    1. I want the full month view to show some of the text of each event:  Like Pocket Informant and Monthly Calendar Mocha do (not just a dot).
    2. That both of us can post and see each other's events.
    3. That each of us can post "private" events that the other person won't see on their phone.  Things like, "Wife's surprise party."
    4. That sync's both calendars automatically.
    I know a lot of people use Fantastical, but I don't think that would give me the text in the full month view.
    Is there an app that can do all of the above?
    Thanks in advance.
    Rick

    Sharing and syncing is a feature of the calendar database; you can have multiple calendars, and each can be private, shared with specific other iCloud users, or public. If you have a Mac you can set that up in the Calendar app; for either Mac or Windows you can set it up by logging in to iCloud.com using your Apple ID.
    The other calendar apps all use the Apple calendar database; they just have different ways of presenting the content, and can also take advantage of "hidden" features of the Apple calendar database (such as adding icons to entries).

  • Public static vs private

    Hi
    I have 3 classes, A, B & C.
    I have one variable, var, that can be used in class B and C; I have declared it in class B, and passed when I create an istance of C in B.
    Then I need also to read its value in class A.
    Now the ways are two (I think ...):
    1. declare it as public static in class A and then use A.var in class B and C;
    2. declare it as private in A and then passed to B when I create in A an istance of B and to C then I create in B an istance to C.
    Considerations:
    a. I don't like to declare public variables, I think is a bad way to program,
    isn'it?
    b. the second way is a problem when I have 10 variables (the constructors have too many parameters), right?
    Could anyone help?

    The problem is I tryied to find these answer in
    Intenrnet, but I don't find anything.That's fine. That's why most of us are here.
    My application works as this:
    I have a main class (A) that have a main menu in
    console style; from this class I create a new client
    class (B) that receive commands from a server; if a
    command is valid, B create an istance of C that
    rappresents a trainer machine. In C I have all
    workout variables (time, incline, speed ...).
    By menu (in class A) i could pause the trainer and by
    A and/or remote server I could ask the state of the
    machine (C).
    In your explanation above, I draw your attention to "instance". You are making instances of your classes. That being the case, your variables should probably be instance variables
    NOT
    public static int firstVariable = 0;BUT
    protected int firstVariable = 0;You would then provide get and set methods to access the protected variable.
    If you find yourself writing B b = new B() then you know you are dealing with an instance and you should avoid all static variables unless you really do mean "this value is the same across all Bs".
    I have 8 state variables I could manage in that way.
    The only way I have for now found is definite a
    public static long vars in C (and use them in A e B
    as C.state, C.time, ...) to avoid to pass 8
    parameters when I create the istances from A to C.Assuming that C has eight variables and your design isn't done yet you can still pass an instance of C to the other objects. They don't need to have their method/constructor signatures changed when you add a new variable as your C object encapsulates it already.
    >
    Is right? Any other suggestion?Yes. Don't stick to "C.time" because that's what you've got so far. Instead, you should be using
    C c = new C();
    c.getTime();That way, the time variable is unique to the instance.

  • Clustered Environment - Changing from Public Network to Private Network

    I have a clustered environment where the database sits on one node and the central instance sits on the other node. We just found out that somehow the communication between the database and central instance has been changed to talk over the public network instead of the private network. We don't know who did it or why.
    So, my question is what do I need to do in SAP to accomodate the changing back to using the private network? Do I need to change system names in the profiles? Are there any gotchas on doing this? Are there any documents on doing this?
    Thanks for any information you can provide on this topic.
    Thanks,
      -- Jackie

    This is most likely a name resolving problem.
    If you ping <name> from one server to the other, which network is used?
    Markus

  • NAT public /24 to private /24

    Greetings,
    I am looking for an easy way to NAT a public /24 to a private /24. Instead of me having to make NAT statements for each IP address it would be great if it was possible to do in one statement.
    Is has to be one-to-one x.x.x.1 mapped to y.y.y.1, x.x.x.2 to y.y.y.2 etc.
    Is this possible with ASA 5545 running 9.22, and how?
    Regards
    Kenneth

    Hi Kenneth,
    In ASA version 8.3+ you can use Auto NAT to achieve the desired results.
    Create one object network for private subnet and one for public subnet. See example:
    object network INSIDE
     subnet 10.1.1.0 255.255.255.0
    object network OUTSIDE
     subnet 30.1.1.0 255.255.255.0
    Then under the private subnet, define the nat statement.
    object network INSIDE
     subnet 10.1.1.0 255.255.255.0
     nat (inside,outside) source static INSIDE OUTSIDE
    HTH
    "Please rate useful posts and mark the answer as correct if it solves your issue"

  • Public vs. Private iTunes U Site

    Can someone please correct or confirm my interpretations?
    1. The iTunes U Private and Public sites are totally un-linked as far as content?  The content copy was one time, all other files will have to be uploaded to each location separately?
    2. The access role All@urn:mace:itunesu.com... is now non-functional in iTunes U private site?
    3. iTunes U private site will no longer generate RSS feeds of content?
    Thanks for any insight you can add.
    .\.\att

    The below in BOLD is what I am trying to do, but do not have an option to do.  Is this something Apple must give me a role or permission to do?  I am already and Administrator..  Thanks in advance!
    To add content to your site you must create collections containing the course content, series information, or items you want to share with your users.
    To add a collection:
    Click Collections at the top of iTunes U Public Site Manager.
    Click the Add button.
    Choose one of the following from the pop-up menu:iTunes U Public Site Manager adds the new collection to the collections manager page.
    Provider-Hosted Feed. Choose Provider-Hosted Feed to add a new collection from a feed URL hosted on your servers, type the feed URL, and then click Add. For example, http://www.example.com/rss/provider-hosted-collection.rss.
    Apple-Hosted Feed. Choose Apple-Hosted Feed, if available, to add and edit a new collection from a new RSS feed hosted on Apple's servers, click Add, and then use the feed editor to add channel and item details and upload content.
    Copy from Original iTunes U Site. Choose “Copy from Original iTunes U Site” to add a new collection by copying a group from your original iTunes U site, type the group URL, and then click Add. To copy a group from your original iTunes U site, navigate to the group, Control-click the group's tab, choose Copy Link, and then paste the link in the Group URL field.You must be an administrator to use "Copy from Original iTunes U Site". You cannot use "Copy from Original iTunes U Site" to add a feed course from your original iTunes U site.Once you publish your site, you can no longer use "Copy from Original iTunes U Site" to add a collection in iTunes U Public Site Manager.
    If you add, remove, or hide a collection or update an iTunes U Public Site Manager page, you must publish your site for the changes to appear in iTunes U in the iTunes Store. Publishing changes can take up to 24 hours to appear in the iTunes Store.

  • MeetingPlace Express:1st adress Public and second private

    Hello,
    We know that MPE must have 2 IP address.
    But my question is : is it possible top make this design : the 1st IP addres is Public, and the second will be private.
    The public address will serve as Web, voice and video (sip or H323 trunk or gatewa), the private address connect to another Voice Gateway that is inside a LAN.
    Best regards

    No, that design is not possible; the two NICs are utilized for different puproses and this behavior cannot be changed. Also, MPE requires a second server - the Segmented Meeting Access (SMA) server - for external/public access. The internal server is not intended to be publically accessible on the internet.

  • Cannot connect to WiFi in public areas or private or Ad Hoc connections

    I have a 32 GB iPod Touch 2G that is running 4.2.1
    All has been going well, until last week. I tried to connect to a public WiFi (that I have connected to 50 times or more) and it said "Cannot connect to Network". I tried everything that I know how to do, but nothing worked. I then went to another public WiFi (with WEP), but could not get on there either. I then went home and tried to connect to my computer through an Ad Hoc WiFi connection (since we do not WiFi at our house), but I was not able to connect there either.
    I reset it, I synced it, but the problem persists.
    I always have the iPod on Airport mode, so as not to run the battery down. I then take it off Airport mode, turn on WiFi, and wait for the Network to show up on the iPod Touch. I then press the Network that I want. It immediately gives me the check mark next to the Network name, then later it gives me the WiFi symbol at the top left of the screen. I then wait for the Login page...it never comes up. I then go to Safari to force it to come up, but nothing. It says that I am not connected to a Network. I then get fed up with it and try to turn off WiFi, but the Network name stays, even though the WiFi is Off. I then try to turn on the Airport mode, but the airplane does not show up. I try and try to get away from the network, but it will not reset to normal until I press the Home button and the On/Off button together. I then get the circle of dashes (but just a short 1 and 1/2 rotations - ODD), then the black screen. Then I press the On button and get the Apple symbol. Then I sign in and the Airplane is there and the WiFi is off...till I try again. No connections and then I have to repeat this to get it back to half way normal.
    Please help me with this situation. I really do not want to restore the iPod Touch, since I do not have a WiFi network near me...and I have a lot of apps that would have to be set-up through WiFi (taking a lot of time). My fear (if you could call it that), is that if I restore the iPod Touch, and find out that the WiFi problem persists...then I will not be able to use a number of Apps that I use a lot.
    There has to be a simpler answer to this situation.

    +Comment on #2. I'm not aware of any offline apps working with an iPod touch that hasn't been jailbroken. If you have jailbroken your device, we really can't help you here per the terms of service of this website. However, if this just updated data for a legit app or a web app, then it you are going to have to get network access working for it to work and, as you have said, iTunes isn't going to do it.+
    Answer to #2: For one thing, the iPod Touch that I have is NOT jailbroken. I have never jailbroken any of my devices. I am a big supporter of Apple products, because they work. If a device is jailbroken, essentially taking Apple's expertise out of the equation. If I wanted to do that, I would use Android, and suffer with the fragmentation that they suffer with (along with all the problems jailbroken devices have). Enough on that.
    Offline Wiki is an approved app from the AppStore (it is Wikipedia in your pocket, without the Internet). You download the app from iTunes. It is useless till you then download the content (whichever language that you want - for example the one I want, English is 3 GB of space). Since I am not in a WiFi area, and I do not visit WiFi areas often (nor for any real length of time, downloading 3 GB of information takes hours (nearly three hours, when I first did it). The only reason that I was reluctant to Restore my iPod Touch, was to avoid having to do that process again, and not being able to use the app (which I use a lot) until I do spend the time to download the Wikipedia Database onto my iPod Touch.
    +A comment on #1. Those websites that require you to login again - this is a function of the network setup at that site. In effect, they are expiring your lease as soon as you disconnect. When you log in again, you are treated as a completely new user.+
    Answer to #1: Yes, I understand that. Thank you.
    Good luck on the restore.
    Thank you. This, unfortunately was what I had to do. As expected, but not for sure, the WiFi is now working again. It seems that my iPod Touch got corrupted (within the iOS). The reinstalling wasn't as bad as I thought it would be, except I do not have the use of Offline Wiki (since my visit to the doctor yesterday was only for an hour, which I used to update all the other things that I needed WiFi access for. I started the download process, but it will take at least 2 hours to finish).
    Conclusion: The only way to fix this situation, as far as I can tell, is to Restore your iPod Touch. Thank you for reading my long windedness. Also, thank you "luvlabs" for our conversation (though we haven't seen eye-to-eye much in the conversation, but I appreciate the time you spent to try. Thank you.
    Message was edited by: Fr. Ignatius

  • Configuration Help Needed - Layout of Public Access and Private Access Network

    HELP
         I need help in laying out the following network - herre is my first stab at it.
    1. Actiontec DSL Modem - DHCP On     ----- Model GT701-WG
       WAN IP Address 12.17.66.203
       WAN SubNet Mask 255.255.255.255
       Lan IP Address 192.168.0.1
       Lan SubNet Mask 255.255.255.0
    2. WRT54G - DHCP On ----------------  Open to Public Access to the Internet
       Local IP Address 192.168.1.1
       Subnet Mask 255.255.255.0
    3. DellPowerConnect 2708 Switch ---  Open to Public Access to the Internet
    4. MS Windows SBS2003 Server   --- Closed to Public Access
        Connecting to the #2 WRT54G thru a Linsys network card
    5. WRT54G - DHCP Off - ??? --------- Closed to Public Access
        Connecting to another Linksys network card in the SBS2003 Server
       Local IP Address 192.168.1.2     ???
       Subnet Mask 255.255.255.0
    6. Linksys SD216 Switch                 --- Closed to Public Access
    Any help would be greatly appreciated

    I got the network setup, but did not get what you are trying to do. Do you have 2 WRT54Gs there? Are you trying to turn off DHCP server of second WRT54G? A detailed information would be appreciated.

  • J2ME problem with threads

    Hi all,
    I would like to ask you for a help. I need to write a small program at my university. I started to write a midlet which function would be to countdown time for sports activities. I woul like to start a new thread - the one that counts down - and at the same time make the main thread sleep. After the "countdown" thread finishes, the main thread wakes up and waits for user input. The problem is that when the "countdown" thread finishes his work, I've got Uncaught exception java/lang/NullPointerException. error and the midlet halts.
    Below you can find the code
    import java.lang.*;
    import java.util.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    public class intervals extends MIDlet implements CommandListener
    public Display ekran;
    private SweepCanvas sweeper;
    private Form rundy;
    private TextField round0, round1, round2, round3, round4, round5, round6, round7, round8;
    private long czas,x;
    private Command exitCommand;
    private Command addRound;
    private Command delRound;
    private Command start;
    private TextField repeat;
    private Form odliczanie;
    private Alert ostrz;
    Licznik thread;
    String test;
    StringItem test1;
    int parz,i,j,k;
    static int l;
    int ilrund;
    int ilpowt;
    Item sec;
    long sec1;
    public intervals()
        rundy = new Form("Interwa&#322;y sportowe");
        exitCommand = new Command("Wyj&#347;cie", Command.EXIT, 2);
        addRound = new Command("Dodaj","Dodaj rund&#281;", Command.ITEM,1);
        delRound = new Command("Usu&#324;","Usu&#324; ostatni&#261; rund&#281;", Command.ITEM,1);
        start = new Command("Start", Command.ITEM,1);
        odliczanie = new Form("Odliczanie");
        TextField dodaj(TextField kolej)
            kolej=new TextField("Podaj czas (s) rundy "+parz,null, 4, TextField.NUMERIC);//stworzenie nowej instancji do wybierania czasu trwania rundy
            if(rundy.size()==0)
                rundy.insert(rundy.size(),kolej);
                else
                    rundy.insert(rundy.size()-1, kolej);
            return kolej;
        void odliczanie(TextField round)
            monitor m=new monitor();
            k=Integer.parseInt(round.getString());
            ekran.setCurrent(odliczanie);
            thread=new Licznik(k,odliczanie);
            thread.start();
            ekran.setCurrent(rundy);
    public void startApp()// throws MIDletStateChangeException
        rundy.deleteAll();
        repeat = new TextField("Podaj ilo&#347;&#263; powtórze&#324;",null,1,TextField.NUMERIC);
        rundy.addCommand(addRound);
        rundy.addCommand(exitCommand);
        rundy.setCommandListener(this);
        Canvas obrazek = new MyCanvas();
        ekran = Display.getDisplay(this);
        ekran.setCurrent(obrazek);
        czas=System.currentTimeMillis();
        while (System.currentTimeMillis()<czas+1000)
            continue;
        ekran.setCurrent(rundy);
    public void pauseApp()
    public void destroyApp(boolean unconditional)
        notifyDestroyed();
    public void commandAction(Command c, Displayable s)
        if (c == exitCommand)
            destroyApp(false);
            notifyDestroyed();
        else if(c==addRound)
            if(rundy.size()==0)//Sprawdzenie ilo&#347;ci elementów w celu poprawnego wy&#347;wietlania liczby rund w formie
                parz=1;
                else
                parz=rundy.size();
            switch(parz)
                case 1:
                    round0=dodaj(round0);break;
                case 2:
                    round1=dodaj(round1);break;
                case 3:
                   round2= dodaj(round2);break;
                case 4:
                    round3=dodaj(round3);break;
                case 5:
                    round4=dodaj(round4);break;
                default:
                    ostrz=new Alert("Uwaga","Maksymalna liczba rund wynosi 9", null, AlertType.INFO);
                    ostrz.setTimeout(3000);
                    ekran.setCurrent(ostrz);
            if(rundy.size()==1)
                rundy.append(repeat);
                rundy.addCommand(start);
            rundy.addCommand(delRound);
        else if(c==delRound)
            if(rundy.size()!=0)
                rundy.delete(rundy.size()-2);
                if (rundy.size()==1)
                    rundy.deleteAll();
                if(rundy.size()==0)
                    rundy.removeCommand(delRound);
                    rundy.removeCommand(start);
        else if(c==start)
            ilrund=rundy.size()-1;
            if(this.repeat.size()>0)
                ilpowt=Integer.parseInt(this.repeat.getString());
            ekran = Display.getDisplay(this);
            for (i=1; i<=ilpowt;i++)
                odliczanie= new Form("Odliczanie");
                 for (j=0;j<ilrund;j++)
                    switch(j)
                         case 0:
                             odliczanie(round0);
                             break;
                         case 1:
                             odliczanie(round1);
                             break;
                         case 2:
                             odliczanie(round2);
                             break;
                         case 3:
                             odliczanie(round3);
                             break;
                         case 4:
                             odliczanie(round4);
                             break;
                         case 5:
                             odliczanie(round5);
                             break;
                         case 6:
                             odliczanie(round6);
                             break;
                         case 7:
                             odliczanie(round7);
                             break;
                         case 8:
                             odliczanie(round8);
                             break;
    class Licznik extends Thread
        int czas1,k;
        Form forma;
        monitor m;
        public Licznik(int k,Form formap)
            czas1=k;
            forma=formap;
        public synchronized void run()
            while(czas1>0)
                forma.deleteAll();
                forma.append("Czas pozosta&#322;y (s): "+czas1);
                try{Thread.sleep(1000);} catch(InterruptedException e){e.printStackTrace();}
                czas1--;
            if(czas1<=0)
                m.put();
        }and monitor class
    public class monitor
    boolean busy=false;
    synchronized void get()
        if(!busy)
            try
                wait();
            }catch(InterruptedException e){e.printStackTrace();}
        notify();
    synchronized void put()
        if(busy)
            try
            wait();
            }catch(InterruptedException e){e.printStackTrace();}
        busy=true;
        notify();
    }Can anybody help me with this?

    Groovemaker,
    Your Licznik class has a member m of type monitor, which has not been instantiated (in other words is null) hence, when calling m.put() you get NullPointerException. Please also mind, that using Thread.sleep(1000) is not an accurate way of measuring time.
    If I may, please use recommended for Java class naming conventions - some of your names use lower case, while other don't which is confusing to the reader.
    Daniel

  • Problem with Threads and "plase wait..."-Window

    Hi everyone,
    I have a problem that I'm not able to solve in any way... I have a time-consuming task (a file decryption) which I execute in a separate thread; I've used the SwingWorker class, like suggested by sun-tutorial, and it works right. The problem is that I have to wait that the decryption have finished before continuing with program-execution. Therefore I would like to display a "please wait"-window while the task runs. I've tryed all the possible ways I know but the problem is always the same: the waitWindow is displayed empty, the bounds are painted but the contents no; it's only painted when the decrypt-task has finished. Please help me, I have no more resources....
    decrypt-file code:
    public class DecryptFile {
      private String cryptedFileNameAndPath;
      private ByteArrayInputStream resultStream = null;
      // need for progress
      private int lengthOfTask;
      private int current = -1;
      private String statMessage;
      public DecryptFile(String encZipFileNameAndPath) {
        cryptedFileNameAndPath = encZipFileNameAndPath;
        //Compute length of task...
        // 0 for indeterminate
        lengthOfTask = 0;
      public ByteArrayInputStream getDecryptedInputStream() {
        return this.resultStream;
       * Called from ProgressBarDemo to start the task.
      public void go() {
        current = -1;
        final SwingWorker worker = new SwingWorker() {
          public Object construct() {
            return new ActualTask();
        worker.start();
       * Called from ProgressBarDemo to find out how much work needs
       * to be done.
      public int getLengthOfTask() {
        return lengthOfTask;
       * Called from ProgressBarDemo to find out how much has been done.
      public int getCurrent() {
        return current;
      public void stop() {
        current = lengthOfTask;
       * Called from ProgressBarDemo to find out if the task has completed.
      public boolean done() {
        if (current >= lengthOfTask)
          return true;
        else
          return false;
      public String getMessage() {
        return statMessage;
       * The actual long running task.  This runs in a SwingWorker thread.
      class ActualTask {
        ActualTask () {
          current = -1;
          statMessage = "";
          resultStream = AIUtil.getInputStreamFromEncZip(cryptedFileNameAndPath); //here the decryption happens
          current = 0;
          statMessage = "";
      }The code that calls decryption and displays waitWindow
          final WaitSplash wS = new WaitSplash("Please wait...");
          final DecryptFile cryptedTemplate = new DecryptFile (this.templateFile);
          cryptedTemplate.go();
          while (! cryptedTemplate.done()) {
            try {
              wait();
            } catch (Exception e) { }
          this.templateInputStream = cryptedTemplate.getDecryptedInputStream();
          wS.close();Thanks, thanks, thanks in advance!
    Edoardo

    Maybe you can try setting the priority of the long-running thread to be lower? so that the UI will be more responsive...

  • Java Threads compilation problem

    Hi everyone,
    I've having problems getting a simple thread program to compile, the programs says " ; " expected when there is already one present. I've gone through the program many times and still can't put my finger on whats going wrong. If someone could take a quick look and if possible tell me where I am going wrong.
    Many Thanks
    Its class ThreadA that will not compile
    ***code********************************************
    public class ThreadA extends Thread
    private int id;
    public ThreadA(int i) (id = i);
    public void run()
    for (int i=0}; i < 10; i++);
    try {sleep(1000};)catch (InterruptedException e)();
    System.out.println("Output from Thread " + id);
    import java.io.*;
    public class TestThreads1
    public static void main (String args [] )
    Thread t1 = new ThreadA (1);
    Thread t2 = new ThreadA (2);
    Thread t3 = new ThreadA (3);
    t1.start();
    t2.start();
    t3.start();
    **code***********************************************************

    public class ThreadA extends Thread
    private int id;
    public ThreadA(int i) (id = i); // <-- problem
    public void run()
    for (int i=0}; i < 10; i++); // <-- two problems
    try {sleep(1000};)catch (InterruptedException e)(); // <-- more problems
    System.out.println("Output from Thread " + id);
    }

  • Client/Server in one program (using multiple threads)?

    Is there some examples out there of how to use a client and server in a single program using separate threads? Also, is it possible to start a third thread to control the packets, such as drop a random or specified number of packets (or match on specific data in a packet)?

    Just trying to have a client send udp packets to a server (all on the same machine running from the same program) and want to be able to drop packets coming from the client side to the server side.
    E.g.,
    Here's an example that I found here: http://compnet.epfl.ch/tps/tp5.html
    import java.io.<strong>;
    import java.net.</strong>;
    import java.util.<strong>;
    /</strong>
    * Server to process ping requests over UDP.
    public class PingServer {
         private static double lossRate = 0.3;
         private static int averageDelay = 100; // milliseconds
         private static int port;
         private static DatagramSocket socket;
         public static void main(String[] args) {
              // Get command line arguments.
              try {
                   if (args.length == 0) {
                        throw new Exception("Mandatory parameter missing");
                   port = Integer.parseInt(args[0]);
                   if (args.length > 1) {
                        lossRate = Double.parseDouble(args[1]);
                   if (args.length > 2) {
                        averageDelay = Integer.parseInt(args[2]);
              } catch (Exception e) {
                   System.out.println("UDP Ping Server");
                   System.out.println("Usage: java PingServer port [loss rate] [average delay in miliseconds]");
                   return;
              // Create random number generator for use in simulating
              // packet loss and network delay.
              Random random = new Random();
              // Create a datagram socket for receiving and sending UDP packets
              // through the port specified on the command line.
              try {
                   socket = new DatagramSocket(port);
                   System.out.println("UDP PingSever awaiting echo requests");
              } catch (SocketException e) {
                   System.out.println("Failed to create a socket");
                   System.out.println(e);
                   return;
              // Processing loop.
              while (true) {
                   // Create a datagram packet to hold incoming UDP packet.
                   DatagramPacket request = new DatagramPacket(new byte[1024], 1024);
                   // Block until the host receives a UDP packet.
                   try {
                        socket.receive(request);
                   } catch (IOException e) {
                        System.out.println("Error receiving from socket");
                        System.out.println(e);
                        break;
                   // Print the received data.
                   printData(request);
                   // Decide whether to reply, or simulate packet loss.
                   if (random.nextDouble() < lossRate) {
                        System.out.println("   Reply not sent.");
                        continue;
                   // Simulate network delay.
                   try {
                        Thread.sleep((int) (random.nextDouble() * 2 * averageDelay));
                   } catch (InterruptedException e) {}; // Ignore early awakenings.
                   // Send reply.
                   InetAddress clientHost = request.getAddress();
                   int clientPort = request.getPort();
                   byte[] buf = request.getData();
                   DatagramPacket reply = new DatagramPacket(buf, buf.length,
                             clientHost, clientPort);
                   try {
                        socket.send(reply);
                   } catch (IOException e) {
                        System.out.println("Error sending to a socket");
                        System.out.println(e);
                        break;
                   System.out.println("   Reply sent.");
          * Print ping data to the standard output stream.
         private static void printData(DatagramPacket request) {
              // Obtain references to the packet's array of bytes.
              byte[] buf = request.getData();
              // Wrap the bytes in a byte array input stream,
              // so that you can read the data as a stream of bytes.
              ByteArrayInputStream bais = new ByteArrayInputStream(buf);
              // Wrap the byte array output stream in an input stream reader,
              // so you can read the data as a stream of characters.
              InputStreamReader isr = new InputStreamReader(bais);
              // Wrap the input stream reader in a buffered reader,
              // so you can read the character data a line at a time.
              // (A line is a sequence of chars terminated by any combination of \r
              // and \n.)
              BufferedReader br = new BufferedReader(isr);
              // We will display the first line of the data.
              String line = "";
              try {
                   line = br.readLine();
              } catch (IOException e) {
              // Print host address and data received from it.
              System.out.println("Received echo request from "
                        + request.getAddress().getHostAddress() + ": " + line);
    }I'm looking to do the "processing loop" in a separate thread, but I'd also like to do the client in a separate thread
    So you're saying, just put the client code in a separate class and start the thread and that's it? As far as the packet rate loss thread, is this possible to do in another thread?

Maybe you are looking for

  • [ SPED PIS/COFINS ] Impostos Retidos na Fonte em Documento Fiscal

    Bom dia a todos! Verificar os pré-requisitos da nota 1517574 (SPED-EFD PIS/COFINS: Electronic Fiscal File - Overviw Note) não está sendo tão fácil quanto parece! É o seguinte: temos já o ECC Ehp4 SAP_APPL nível 07 e, segundo o que há na nota acima me

  • Vendor bank data(IBAN value) populated in 2 lines version 2

    Hello guys, Pls, i need a little help. I'm trying to migrate the VENDOR MASTER DATA. I've filled the tables in LSMW (using BDC): BLFA1 BLFB1 BLFBK BLFBK_IBAN BLFM1. LSMW creates the session, but when i get to BANK Screen, it inserts 2 lines for a sin

  • NAT holes in Solaris 10 x86

    I am using the bundled IPFILTER software on Solaris 10 x86. I find quite a few random requests going out on the external interface with an internal IP address (those requests are not being NAT-ed). This does not happen with all requests though.. only

  • Diagnostics Agent 711 - SAP Host Agent - Installation on a cluster environm

    Dear all, We have the following architecture in our productive environment : 1. Cluster 01 is composed of 2 nodes.    On Cluster 01, only "Database" and "Central Services" are running    for 5 productive SAP systems. 2. Cluster 02 is composed of 6 no

  • TimesTen 11.2 version : native error 778

    Hello, We are trying to integrate 64-bit 11.2.1_9 TimesTen. and we are getting the following error when performing UPDATE ....................... WHERE ROWID=? operation. execute on 'SQLExecute(Select then Update: Update) state=S1000 msg=[TimesTen][T