Thread unsafe - make it safe

class PageServlet extends HttpServer {
    String id;
    public void doGet(HttpServletRequest request,
              HttpServletResponse response)
    throws ServletException, IOException
        id = request.getParameter("ID");
        out.println("Your id is "+id);
The id variable used above is shared by all the threads created.
How can i make id local to each thread. Such that each thread uses its initialized value, without moving the variable id inside the doGet method?
(Note: This is problems reflects a problem in a big sized servlet. That is the reason why just moving the id inside doGet method does not solve the problem.)
Any suggestions?
Thank you

I dont know what you mean hereThe servlet container (Tomcat, whatever) creates an HttpServletRequest object for each user request. This object exists roughly from the moment the user's browser sends a request to your server to the time your servlet finishes sending HTML back to the browser (so, a fraction of a second). It's common to pass control between different servlets within the server. So servlets use the request as a shared bucket to store various intermediate values. They are stored as attributes (effectively a HashMap).
public void doGet(HttpServletRequest request, HttpServletResponse response) {
    String id = request.getParameter("ID"); // This gets the value that the browser sent
    request.setAttribute("id", id);
    doSomeStuff(request, ...);
private void doSomeStuff(HttpServletRequest request, ...) {
    String id = (String) request.getAttribute("id");
}

Similar Messages

  • My server was under dictionary attack - how to make it safer?

    Yesterday my server was "hit" for half an hour by someone using a dictionary. Fortunatly he was not able to get access, but I would like some advice on what I could do to try to make it safer. Like for instance is it possible to completely block an IP address after 5 tries from it?
    Here is a snip of my logs:
    Jul 16 03:35:15 pkmainserver pop3[5809]: badlogin: [193.33.170.11] plaintext info
    Jul 16 03:47:02 pkmainserver pop3[6063]: badlogin: [193.33.170.11] plaintext guest
    Jul 16 03:47:05 pkmainserver pop3[6064]: badlogin: [193.33.170.11] plaintext mailnull
    Jul 16 03:47:09 pkmainserver pop3[6065]: badlogin: [193.33.170.11] plaintext smmsp
    Jul 16 03:47:12 pkmainserver pop3[6066]: badlogin: [193.33.170.11] plaintext squid
    Jul 16 03:47:16 pkmainserver pop3[6070]: badlogin: [193.33.170.11] plaintext webalizer
    Jul 16 03:47:20 pkmainserver pop3[6071]: badlogin: [193.33.170.11] plaintext dbus
    Jul 16 03:47:23 pkmainserver pop3[6072]: badlogin: [193.33.170.11] plaintext xfs
    Jul 16 03:47:27 pkmainserver pop3[6073]: badlogin: [193.33.170.11] plaintext named
    Jul 16 03:47:30 pkmainserver pop3[6074]: badlogin: [193.33.170.11] plaintext ntp
    Jul 16 03:47:34 pkmainserver pop3[6075]: badlogin: [193.33.170.11] plaintext gdm
    Jul 16 03:47:37 pkmainserver pop3[6076]: badlogin: [193.33.170.11] plaintext mysql
    Jul 16 03:47:41 pkmainserver pop3[6077]: badlogin: [193.33.170.11] plaintext manpreet
    Jul 16 03:47:44 pkmainserver pop3[6078]: badlogin: [193.33.170.11] plaintext postfix
    Jul 16 03:47:48 pkmainserver pop3[6079]: badlogin: [193.33.170.11] plaintext clamav
    Jul 16 03:47:51 pkmainserver pop3[6080]: badlogin: [193.33.170.11] plaintext amavis
    Jul 16 03:47:55 pkmainserver pop3[6081]: badlogin: [193.33.170.11] plaintext root
    Jul 16 03:53:45 pkmainserver pop3[6154]: badlogin: [193.33.170.11] plaintext oracle
    Jul 16 03:53:48 pkmainserver pop3[6155]: badlogin: [193.33.170.11] plaintext oracle
    Jul 16 03:53:52 pkmainserver pop3[6156]: badlogin: [193.33.170.11] plaintext oracle
    Jul 16 03:53:55 pkmainserver pop3[6157]: badlogin: [193.33.170.11] plaintext vmail
    Jul 16 04:06:30 pkmainserver pop3[6399]: badlogin: [193.33.170.11] plaintext rami
    Jul 16 04:06:38 pkmainserver pop3[6400]: badlogin: [193.33.170.11] plaintext maha
    Jul 16 04:06:45 pkmainserver pop3[6402]: badlogin: [193.33.170.11] plaintext ntinah
    Jul 16 04:06:52 pkmainserver pop3[6403]: badlogin: [193.33.170.11] plaintext shijazi
    Jul 16 04:06:58 pkmainserver pop3[6404]: badlogin: [193.33.170.11] plaintext daoud
    Jul 16 04:07:03 pkmainserver pop3[6405]: badlogin: [193.33.170.11] plaintext reptegus
    Jul 16 04:07:08 pkmainserver pop3[6406]: badlogin: [193.33.170.11] plaintext psagastume
    Jul 16 04:07:14 pkmainserver pop3[6407]: badlogin: [193.33.170.11] plaintext ndiaz
    Jul 16 04:07:20 pkmainserver pop3[6411]: badlogin: [193.33.170.11] plaintext marriaga
    Jul 16 04:07:26 pkmainserver pop3[6412]: badlogin: [193.33.170.11] plaintext lreyes
    Jul 16 04:07:33 pkmainserver pop3[6413]: badlogin: [193.33.170.11] plaintext lmorales
    Jul 16 04:07:40 pkmainserver pop3[6414]: badlogin: [193.33.170.11] plaintext lgarcia
    Jul 16 04:07:48 pkmainserver pop3[6415]: badlogin: [193.33.170.11] plaintext lcarcamo
    Jul 16 04:07:52 pkmainserver pop3[6416]: badlogin: [193.33.170.11] plaintext kcantarero
    Jul 16 04:07:57 pkmainserver pop3[6417]: badlogin: [193.33.170.11] plaintext jmatute
    Jul 16 04:08:03 pkmainserver pop3[6418]: badlogin: [193.33.170.11] plaintext ivalladares
    Jul 16 04:09:35 pkmainserver pop3[6438]: badlogin: [193.33.170.11] plaintext qmaill
    Jul 16 04:09:43 pkmainserver pop3[6439]: badlogin: [193.33.170.11] plaintext spam
    I also left the person's IP. Maybe you know him
    The list in the middle is much much bigger and sometimes the person tried 10+ times the same login (root as an example).
    Advices?

    James Spong wrote:
    make sure that all users have strong passwords with a combination of caps,
    lowercase number and letters. This is especially important for 'core' addresses, such as root, admin, > info etc
    Wait a minute. You should *never* allow remote (external) login for root. If you really must then
    setup dsa ssh keys and disallow access via password & disable use of PAM in /etc/sshd_config
    and limit root access to local IPs (ie: IP ranges owned by your ISP for example).
    Same is true for admin.
    _Do NOT send or receive email as root !!!_
    As for properly securing ssh, better to login as a non-admin account and then su to your admin account.
    Don't use "admin" for your admin account-name.
    And yes of course use strong passwords, but you want to get away from allowing ssh access via password anyway.
    It's not as perfect as I'd like (couldn't edit it after the fact), but see my post about securing ssh
    http://discussions.apple.com/thread.jspa?messageID=7082312&#7082312

  • On the Web Wiz Forum, id="gwProxy" ="" ="ifofjsCall==''jsCall;elsesetTimeout'jsCall',500;" id="jsProxy" ="" is added to every reply that I make. Safe mode cures it but how do I know which add-on is the problem?

    When I go to a reply window, sometimes it almost looks like there is a little window/box appears (with the 6 dots that allows the size to be changed) It appears to be the cause of the string/code?
    On the Web Wiz Forum, < id="gwProxy" ="">< ="ifofjsCall==''jsCall;elsesetTimeout'jsCall',500;" id="jsProxy" ="">
    to be added once the reply is posted, to every reply that I make. Safe mode cures it but how do I know which add-on is the problem? I have 25-30 add-ons.

    Disable all addons by going to Tools -> Addons and clicking the disable button in every entry under Extensions or Plugins panels.
    Restart Firefox.
    Confirm the problem isnt there.
    Enable each addon one by one by going to Tools -> Addons and clicking the enable button in every entry under Extensions or Plugins panels, in such a way that each time you enable ONE addon, you RESTART the browser and see if the problem STILL happens.
    AS SOON AS the problem happens, disable the last addon you enabled. That one is the culprit. You can now enable all the others, if needed.

  • How to make a safe copy of all mails or to export these?

    Hello, I'n newbie on Mac OS X. I've been wondering how to make a safe copy of all mails in my inbox or to export all of them, like on Outlook with the function "Export". I don't find such function under MAIL. Can you please help me? Thanks
    Best regards.

    Hi
    Welcome to Mac Computing.
    The folder holding your e-mail plus mailboxes etc. is located (via the Finder) in your User Account>Library>Mail folder. You can copy this folder to external media, such as another hard drive, or CD/DVD.
    If you want to save specific e-mails, follow these directions from Mail's Help section (Help Menu):
    Exporting email messages:
    You can save one or more messages as a separate file to archive messages or to import the contents into another application. You can open the saved message in TextEdit.
    Open the message you want to export.
    Choose File > Save As, and enter a name for the file.
    Choose a location for the file from the Where pop-up menu.
    Choose a format from the pop-up menu.
    If you choose Rich Text Format, the text formatting of the message will be visible.
    If you choose Plain Text, the colors, fonts, and other formatting will be lost.
    If you choose Raw Message Source, the full delivery headers will be visible. If the message has attachments, you'll only see the encoded version of the attached files.
    A Good way to familiarize yourself with OS X is to pick up a copy of Scott Kelby's book OS X Tiger: Killer Tips.
    Post back

  • ][Music] Make Spotify Safe While Driving

    Dear Spotify, As someone who loves to jam out in my car, I (and I'm sure many others) would love a feature that makes it safer to skip, pause, and play songs while driving. In my experience trying to find safe driving apps for music streaming, I could never find one that was compatible with Spotify. So I'd like to suggest a possible add-on or app that would make Spotify jamming safer for drivers. Maybe something with features like double-tap to pause and play, swiping left or right to skip or go back to songs, tap and hold for microphone and talk-back commands to request playlists or artists. I have an app on my Motorola called "Assist" that detects when I'm driving through GPS. Maybe a feature like that could work with this app too. I'm sure theres a lot more to consider when making an app. I'm not too informed in subjects like this but I hope this is a helpful suggestion if ya'll need ideas on how to make it easier for users to blast "Get Low" by Lil John out their cars hands-free. To the windooooooww to the waaaaalllll!!! Till sweat drops down my.... Sincerely,  Giselle

    Updated: 2015-07-29Hello Giselle and thanks for the feedback!
    Any news regarding this request will be announced in the original idea topic here:
    https://community.spotify.com/t5/Live-Ideas/Car-Mode-Better-amp-faster-usability-for-choosing-and-playing/idi-p/1014795
    Please add your kudos and comments there, if you haven't already. ;)

  • How to stop a threads that makes I/O calls ?

    Hi,
    I've a business method that calls a Stored Procedure and makes lots of calculations. This method works inside its own thread, because I do not want to stop the GUI from accepting user actions.
    My problem is : this method may take from 5 minutes to 1 hour to process, depending on the size of the input. Sometimes, for any reason at all, the user may want to stop this execution (pressing a button on the GUI). How can I safely stop the thread ?
    I know I should not use stop() and suspend() because they are deprecated. And I do not use loops (remember it calls only a StoredProcedure that makes all processing), so I cannot use a variable nor interrupt(), because they do not work.
    Do you know any other way to stop this thread's execution ? By the way destroy() is not implemented.
    Thanks and regards.
    Bruno

    Are you saying that the 5 minutes to an hour is all spent in the stored procedure?
    If so the only real solution is to kill the statement - I'm not sure how the DB will handle that, but it will certainly free up your cycles.
    To do that without violating encapsulation, you just need to keep a reference to an object that knows something about the DB connection - you don't have to actually pass around the JDBC objects.
    Consider an object like this:
    public class DoLongProcedure {
       private Statement dbStatement;
       public double doLongCalculation() {
          dbStatement.execute(...);
          // etc
       public void interruptCalculation() {
          dbStatement.close();
    }You create an instance of this object and call its doLongCalculation() method to start everything. You have a reference to this object somewhere, because you are waiting for a response. When the user wants to cancel the process you just call the interruptCalculation() method.
    You have not violated your separation of functionality - if you find a new way to stop the process without killing the statement later, you just reimplement that method.

  • Windows 10: new security features make PCs safer for users and businesses

    Windows 10 doesn't only deliver various visual and functional updates.
    The latest and most advanced OS from Microsoft has an abundance of new security features under the hood which ensure safer computing for consumers and businesses. 

    there is a new windows service installed with this beta vrsion of the console launcher
    why the hell do you?need to add a new serivce all the time. First you added CTAudSVC.exe with the?latest drivers... and now there is some sort?of ct engine licensing service..... We?need fixes not?memory hogging services.

  • How to use Multi Thread to make a animation

    Hello
    Currently i am writing a router simulator using Java SE 1.4.2. I am facing a problem that is I cannot use multithread to update my Jframe animation.
    Here i give my approach.
    My idea is I used a JPanel in JFrame and I used Graphics g draw all background in Jpanel and add it into Jframe. It works since there is no animation invovled. I want to do some animation based on this background which i draw. But all animation should be controled by other threads due to i want other threads can control all animation. But i hit a error which is nullpointexception. The reason looks like which i used another to do animation, it cannot find the reference which is point to the Jpanel and Jframe. May u teach me a correct way to do multi threads animation in Jframe? thanks.
    all the best and regards!

    A simple annimation moving a circle round a screen. This uses a model that defines the dynamics of the annimation, a view to display a visual representation of the model and an event system (observer/observable) to notify the view that the model has changed.
    I hope this helps.
    import java.awt.*;
    import javax.swing.*;
    import java.util.*;
    public class Test20041023 extends JFrame
        public Test20041023()
            super("Simple Annimation Demo");
            AnnimationModel annimationModel = new AnnimationModel();
            AnimationView animationView = new AnimationView(annimationModel);
            setContentPane(animationView);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            pack();
        private static class AnimationView extends JPanel
            private static final int PREFERRED_WIDTH = 512;
            private static final int PREFERRED_HEIGHT = 256;
            AnimationView(AnnimationModel annimationModel)
                // Save a reference to the model for use
                // when the view is updated
                annimationModel_ = annimationModel;
                // Listen for the events indicating that the model has changed
                annimationModel_.addObserver(new Observer()
                    public void update(Observable o, Object arg)
                        // All we need to do is to get the view to repaint
                        AnimationView.this.repaint();
            public void paintComponent(Graphics g)
                super.paintComponent(g);
                // Update the view based on the information in the model.
                g.setColor(Color.red);
                // Convert the model positions to view positions
                // in this case by scaling to the actual width and height.          
                int xScreenPosition = scaleValue(annimationModel_.getX(), getWidth() - 20 ) + 5;
                int yScreenPosition = scaleValue(annimationModel_.getY(), getHeight() - 20 ) + 5;
                // Display the position of the point
                g.fillOval(xScreenPosition, yScreenPosition, 10, 10);
            private int scaleValue(double v, double size)
                return (int)((v+1.0)*0.5 * size + 0.5);
            public Dimension getPreferredSize()
                return new Dimension(PREFERRED_WIDTH, PREFERRED_HEIGHT);
            // The saved reference to the model
            private AnnimationModel annimationModel_;
        private static class AnnimationModel extends Observable
            AnnimationModel()
                Thread annimationThread = new Thread()
                    public void run()
                        // Loop forever updating the model
                        // and notifying the observers.
                        while(true)
                            // Wait 0.05 seconds until the next frame update point
                            try
                                sleep(50L);
                            catch (InterruptedException e)
                                // Nothing to do
                            // Update the model - in this case it is very simple
                            theta_ += 0.1;
                            // Notify the observers
                            setChanged();
                            notifyObservers();
                annimationThread.start();
            // Model access methods
            public double getX()
                return Math.cos(theta_);
            public double getY()
                return Math.sin(theta_);
            // The angular position of the point
            private double theta_;
        // Simple test main
        static public void main(String[] args)
            new Test20041023().setVisible(true);
    }

  • Why can't I use some form of parental control like IE to make it safe for my Kids?

    I am just about to remove Firefox from my pc because I cant figure out how to protect my kids from the crap that is on the web!! I don't want them accidentally getting to an adult site.

    Also, for some (somewhat limited) parental controls in Windows XP, see: http://www.ehow.com/how_5928183_set-parental-controls-windows-xp.html
    Generally, the products mentioned in cor-el's post are more comprehensive than those provided from within Windows XP.
    <br />
    The plugins submitted along with your question, indicate that your have out of date plugins with known security issues. For security reasons. you should update them. To see the plugins submitted with your question, click "More system details..." to the right of your original question post.
    *Adobe Shockwave for Director Netscape plug-in, version 11.5
    *Shockwave Flash 10.0 r32
    *Java Plug-in 1.6.0_04 for Netscape Navigator (DLL Helper)
    #'''Check your plugin versions''': http://www.mozilla.com/en-US/plugincheck/
    #*'''Note: plugin check page does not have information on all plugin versions'''
    #'''Update Shockwave for Director'''
    #*NOTE: this is not the same as Shockwave Flash; this installs the Shockwave Player.
    #*Use Firefox to download and SAVE the installer to your hard drive from the link in the article below (Desktop is a good place so you can find it).
    #*When the download is complete, exit Firefox (File > Exit)
    #*locate and double-click in the installer you just downloaded, let the install complete.
    #*Restart Firefox and check your plugins again.
    #*'''<u>Download link and more information</u>''': http://support.mozilla.com/en-US/kb/Using+the+Shockwave+plugin+with+Firefox
    #'''Update Shockwave Flash'''
    #*Use Firefox to Download and SAVE to your hard drive from one of the links below; '''<u>the links take you directly to the download and you avoid the "getplus" download manager and "extras" (i.e., toolbars, virus scan links, etc.) on the main Adobe page.</u>'''
    #*SAVE to your Desktop so you can find it
    #*After download completes, close Firefox
    #*Click on the file you just downloaded and install
    #**Note: Vista and Win7 users may need to right-click the installer downloaded and choose "Run as Administrator"
    #**Note: Most browsers other than IE will also get updated with this one download
    #**Note: To update IE, same procedure '''<u>but use IE</u>''' to go: http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_ax.exe
    #*After installation, restart Firefox and check your version again.
    #*'''<u>Download links and other information</u>''':
    #** https://support.mozilla.com/en-US/kb/Managing+the+Flash+plugin#Updating_Flash
    #** '''<u>or</u>''' you can download, save, then run the manual installers for IE, then for Firefox (and all other browsers) from here: http://kb2.adobe.com/cps/191/tn_19166.html#main_ManualInstaller
    #* Also see: http://support.mozilla.com/en-US/kb/Installing+the+Flash+plugin
    #* Also see (if needed): http://kb2.adobe.com/cps/191/tn_19166.html#main_Uninstall
    #'''Update Java:'''
    #* Download and update instructions: https://support.mozilla.com/en-US/kb/Using+the+Java+plugin+with+Firefox
    #* Removing old versions (if needed): http://www.java.com/en/download/faq/remove_olderversions.xml
    #* Remove multiple Java Console extensions (if needed): http://kb.mozillazine.org/Java#Multiple_Java_Console_extensions
    #* After the installation, start Firefox and check your version again.

  • How to make arch safe enough to remote desktop?

    I have a dsl connection at home, and I need to remote from work to my home usually.
    Sometimes I need to reboot my computer at home from a remote connection because I need to change to another OS.
    The problem with arch, is that if adsl is not able to connect at startup for some reason, it wont try it later, and I will lost the machine.
    Other distributions, like debian, keeps the daemon running until it connects, or try it later; I can do the same with windows and it dsl connection properties; but so far, I have not been able to do it with arch.
    Thanks in advance

    Well, i'd say pppd knows when it has been disconnected, and quits itself.
    So, ensure you have the flag -detach in your pppd configuration file enabled, and configure your inittab similar to this
    pd:23:respawn:/usr/sbin/pppd
    This would ensure to reconnect when the pppd daemon quits. This might not be the proper arch way to go, but it should work
    That's the commandline version, if you are running KDE, kppp has a reconnect method for pppd.
    The other way would be to write a small shell or perl script to check if the daemon is running or if you still have a connection up.
    Hope it helps
    // STi

  • Is there a Lion-compatible app that strips geotags from photos to make them safe to post online?

    I found "Photo Privacy", but it doesn't mention whether or not it's compatible with Lion.  Thanks!

    Any editor that can edit the Exif should do this -  Exif Editor for instance.

  • How I can make ipad safe browsing for the kids?

    I would like to block adult sites off my kids ipad how can I do that?

    K9 Web Protection Browser:
    https://itunes.apple.com/sg/app/k9-web-protection-browser/id407657840?mt=8

  • Are static nested classes thread-safe?

    There doesn't seem to be any definitive answer to this. Given the following code, is it thread-safe?
    public class SomeMultiThreadedWebController {
    public HttpServletResponse someMethodToExecuteViaWebRequest(HttpServletRequest request) {
        simpleQueryBuilder("SELECT...").addParameter("asdf","asdf").createQuery(EMF.getEntityManager()).executeUpdate();
    protected static class SimpleQueryBuilder {
             private String queryString;
             private Map<String, Object> params = new HashMap<String, Object>();
             public SimpleQueryBuilder(String queryString) {
                  this.queryString = queryString;
             public SimpleQueryBuilder addParameter(String name, Object value) {
                  params.put(name, value);
                  return this;
             public Query createQuery(EntityManager em) {
                  Query query = em.createQuery(queryString);
                  for (Entry<String, Object> entry : params.entrySet()) {
                       query.setParameter(entry.getKey(), entry.getValue());
                  return query;
        public static SimpleQueryBuilder simpleQueryBuilder(String queryString) {
             return new SimpleQueryBuilder(queryString);
    }Forget whether or not someone would do this, as this is just an example. I'm really trying to get at whether or not the instance variables inside the static nested class are thread-safe. Thanks for any responses.

    Hello,
    I believe you understand what you're talking about, but you state it in a way that is very confusing for others.
    Let me correct this (essentially, incorrect uses of the terminology):
    I agree that thread-safe or not is for an operation, for a member, it has some sort of contextual confusion.
    Member has a much broader meaning in the [Java Language Specification|http://java.sun.com/docs/books/jls/third_edition/html/names.html#6.4] . Even "class member" applies to both an attribute, a method, or an inner class or interface.
    I think you mean "member variable" of a class (aka "attribute" or "field"). By the way, static or not is irrelevant to the rest of the discussion.
    For an operation or a member, if there's only one thread could access it atomically in one moment, we could call it thread-safe.Mmm. I was tempted to say yes (I'm reluctant to commit myself). With an emphasis on "_The encapsulating class_ makes this member's usage thread-safe".
    Still, just synchronizing each operation on a member is not enough to make all usages "thread-safe":
    Consider a java.util.Vector: each add/get is synchronized, so it is atomic, fine.
    However if one thread adds several values, let's say 3, one by one, to a vector that initially contains 0 values, and another thread reads the vector's size() (another properly synchronized method), the reader thread may witness a size anywhere among 0, 1, 2, 3, which, depending on the business logic, may be a severely inconsistent state.
    The client code would have to make extra work (e.g. synchronizing on the vector's reference before the 3 adds) to guarantee that the usage is thread-safe.
    Thus any synchronized method(With the limit stated above)
    or immutable member (like primitive type) are thread-safe.
    Additionally for a member, if it's immutable, then it's thread-safe. You mean, immutable primitive type, or immutable object. As stated previously, an immutable reference to a mutable object isn't thread-safe.
    a static final HashMap still have thread-safe issue in practice because it's not a primitive.The underlined part is incorrect. A primitive may have thread-safety issues (unless it's immutable), and an object may not have such issues, depending on a number of factors.
    The put, get methods, which will be invoked probably, are not thread-safe although the reference to map is.Yes. And even if the put/get methods were synchronized, the client code could see consistency issues in a concurrent scenario, as demonstrated above.
    Additional considerations:
    1) read/write of primitive types are not necessarily atomic: section [ §17.7 of the JLS|http://java.sun.com/docs/books/jls/third_edition/html/memory.html#17.7] explicitly states that writing a long or double value (2 32-bits words) may not be atomic, and may be subject to consistency issues in a concurrent scenario.
    2) The Java Memory Model explicitly allows non-synchronized operations on non-volatile fields to be implemented in a "thread-unsafe" way by the JVM. Leading way to a lot of unintuitive problems such as the "Double-Checked Locking idiom is broken". Don't make clever guess on code execution path unless you properly synchronize access to variables across threads.
    Edited by: jduprez on Mar 4, 2010 9:53 AM

  • HASHMAP is it thread safe really?

    Hi all,
    I want to use the Hashmap class in my program but I need to know is it thread safe???
    Thanks
    ps where would I find out information like that?

    I am just wondering what gave u the concept of thread safetyness.........Well its up to u how u make use of it for that matter even a simple program can be thread unsafe u know........ its only the implementation which matters So don't worry take my word and go ahead with that...the class by itself is threadsafe but do a proper implementataion.

  • Thread safe servlets

    I have a question regarding the semantice of servlets. Consider you are calling a method
    public StringmodifyAddress(){......}in the service method of the servlet. Now considering that a servlet could be sericing multiple requests would this method be technically thread safe? If not what could we do to make it safe.
    cheers

    Ok let me rephrase and provide a little more details. Sorry I messed up the question the first time
    private String email;
    public void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException
       User user = new User;
       String address =  user.modifyAddress(email);
    }Now in the class User
    public String modifyAddress(String email)
      //writes the email address to a database
    }Now I feel since user is a variable local to the service method it is thread safe, but a coworker feels that since email is a member variable it would not be thread safe. Please advise it seems that he might be correct.

Maybe you are looking for

  • XML Publisher Looping

    Hello everyone, I have an Invoice XML source which has the following grouping structure: - <TMP002> - <LIST_G_ORDER_BY> - <G_ORDER_BY> <ORDER_BY>111</ORDER_BY> - <LIST_G_INVOICE> - <G_INVOICE> <BILL_CUST_NAME>Name 1</BILL_CUST_NAME> <BILL_ADDRESS1>Ad

  • Oracle Report.  Moving from NT to UNIX

    We are transferring a small web enabled Oracle 9i application (Form 6 + Report 6) from NT to a UNIX Sun server. The application runs, but the font being generated by Report has changed - larger and Bold - in parts of the reports. We were using Arial,

  • Max size of Selector's buffer

    Hello, Is there a maximum size for selector's buffer? Thnx

  • About group by & order by

    SELECT ?move ?road ?submoveslice WHERE { ?move <rdf:type> <u:move>. ?submoveslice <rdf:type> <u:submove_slice>. ?road <rdf:type> <u:road>. ?move <u:has_submove> ?submove. ?submoveslice <u:submove_at> ?submove. ?submove ?relate ?road. Hi,using the abo

  • Error Code -10810.  What is that all about?

    I have been receiving a window with all applications saying that I cannot run the app and has a error code -10810 after the computer has been on for more than a few hours. I need to restart the entire Mac Book Pro to get the apps to work. I am curren