How to make thread safe?

Hi guys,
I got a backing bean like
public class UserBean{
private String firstname;
     public String getFirstname() {
          return firstname;
     public void setFirstname(String firstname) {
          this.firstname = firstname;
the firstname variable is also use in the jsp page like
<h:outputText value="#{userBean.firstname}"/>
If the "setFirstname" method is executed by two threads, then it's likely that the value of the firstnameinstance variable will be replaced by the second thread while the first thread is still using it. So does JSF handle this thread safe condition? Please advice, Thanks !
regards,
kmthien

If the bean is scoped in the request, according to the servlet spec, only one thread should ever access it. If the bean in scoped in the session/application, then it's up to you to manage synchronization within your bean as with every other web framework.

Similar Messages

  • 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

  • Can i make Thread safe without using synchronised keyword in java

    Hi all,
    please tell me code and concept that we can make Thread safe without using synchronised keyword in java programming.
    regards
    Mohan kumar

    There's a series of new features in Java 5.0 (JDK 1.5.0) to address things like concurrency.
    See: http://java.sun.com/j2se/1.5.0/docs/guide/concurrency/overview.html
    -Alexis

  • 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

  • Global Component - How is it thread safe?

    While a global component is serving many sessions and in turn many requests, how is the thread safety guaranteed? How the call stack is maintained?

    It's often possible to write a global component that is thread safe without using locks or synchronize. As long as the component's class member variables are set globally, e.g., via Nucleus configuration, and all thread-specific values are held in method variables (which are housed on the stack), the component is thread safe. If thread-specific values need to be accessed by multiple methods in the class, the values must be passed as formal method parameters rather than through class member variables. Most of the global components that ship in the ATG product stack follow this coding pattern and do not use any kind of locks.

  • How to write thread safe to a file..please help!!

    Hi,
    need a sample writing thread safe to a file.
    thanks

    `Or create a class that has a private BufferedWriter to the file, opened in append mode, and in your "print" or "write" method, synchronize on the BufferedWriter..ie...
    given a BufferedWriter bw that's already open to append mode.
    public void write(String s)
    synchronized(bw)
        bw.write(s);
        bw.flush(0;
    }

  • 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

  • How to make the Thread as a Answered

    Dear Support Team,
    How to make  thread as a Answered one , Because  it still showing Not Answered.I want to change the status as a Answered.
    Re: Price Variance hitting PPV account even when there is stock.
    Thanks for our support.
    Regards,
    Thambi.

    You can close this thread by selecting whichever reply you feel is correct as CORRECT ANSWER. OR if you feel there is no proper reply to correct solution, you may also mark your query as Assumed answered.
    Did you not go through How to close a discussion and why
    Regards,
    Jitendra

  • Thread-Safe BC4J Application

    Hello,
    I have an BC4J-based application, based on BC4J9.0.2. I'm considering to upgrade my BC4J library to upper version to make my application more thread-safe.
    How can I make thread-safe application using BC4J? Is there any specific Rule?
    Thank you.

    Hi,
    Its hard to define a single rule since it depends upon how each application is using threads. I have included some thoughts about the most common scenarios for web clients below:
    The BC4J client wizards (datatags, struts, JClient) will help you generate threadsafe applications. The general rule when writing a web client is to ensure that each "user", as represented by an HttpSession instance, has their own ApplicationModule instance. Using the ApplicationModule datatag or the BC4J/Struts framework will guarantee this.
    Beyond this it may also be necessary to coordinate multiple concurrent requests from a single client (imagine a user pounding on the browser refresh button). One approach for solving this problem is to synchronize requests on some sort of session context. The ApplicationModule tag supports a latching mode (see the lock attribute) which performs this by synchronizing access to the SessionCookie (cached in session, used to acquire ApplicationModule instance). Support for latching will also be available in Struts in the 9.0.3.3 and later timeframe.
    Hope this helps,

  • How to make a global scope component to be thread safe?

    One of my global component preserves states in its member variables, I am afraid that it's might messed up in multi-threading conditions, so how to make a nucleus global component to be thread safe?
    Edited by: user13344577 on Jul 14, 2011 9:45 AM

    Hi,
    Just to help integrate Shaik's and my own seemingly contradictory replies:
    If the member variables in your global component actually need to be globally available, so that multiple threads/sessions need to seem the same data, then you need to use synchronization or some scheme to make this data thread-safe when updating it. If the member variables are non-global data and are simply for convenience of having data available for multiple method calls or something like that, then you should do as I said (don't use synchronization) and use one of my suggestions to avoid this.
    I have seen customers frequently do what I replied about and store non-global data in a global component, and Shaik simply interpreted what "user13344577" is trying to do differently. Clarification is needed to know which of our answers better applies.
    Thanks.
    Nick Glover
    Oracle Support for ATG Products

  • How to make jdbc code thread safe

    Iam using jsp to connect to the data base how to make it is thread safe

    ch.vasu07 wrote:
    Iam using jsp to connect to the data base how to make it is thread safeYou should not be connecting to a database in a JSP. Do that on the server side. JSPs should be pure view.
    Learn JSTL and keep scriptlet code out of your JSPs.
    %

  • Native library NOT thread safe - how to use it via JNI?

    Hello,
    has anybody ever tried to use a native library from JNI, when the library is not thread safe?
    The library (Windows DLL) was up to now used in an MFC App and thus was only used by one user - that meant one thread - at a time.
    Now we would like to use the library like a "server": many Java clients connect the same time to the library via JNI. That would mean each client makes its calls to the library in its own thread. Because the library is not thread safe, this would cause problems.
    Now we discussed to load the library several times - separately for each client (for each thread).
    Is this possible at all? How can we do that?
    And do you think we can solve the problem in this way?
    Are there other ways to use the library, though it is not thread safe?
    Any ideas welcome.
    Thanks for any contributions to the discussion, Ina

    (1)
    has anybody ever tried to use a native library from
    JNI, when the library (Windows DLL) is not thread safe?
    Now we want many Java clients.
    That would mean each client makes its calls
    to the library in its own thread. Because the library
    is not thread safe, this would cause problems.Right. And therefore you have to encapsulate the DLL behind a properly synchronized interface class.
    Now the details of how you have to do that depends: (a) does the DLL contain state information other than TLS? (b) do you know which methods are not thread-safe?
    Depending on (a), (b) two extremes are both possible:
    One extreme would be to get an instance of the interface to the DLL from a factory method you'll have to write, where the factory method will block until it can give you "the DLL". Every client thread would obtain "the DLL", then use it, then release it. That would make the whole thing a "client-driven" "dedicated" server. If a client forgets to release the DLL, everybody else is going to be locked out. :-(
    The other extreme would be just to mirror the DLL methods, and mark the relevant ones as synchronized. That should be doable if (a) is false, and (b) is true.
    (2)
    Now we discussed to load the library several times -
    separately for each client (for each thread).
    Is this possible at all? How can we do that?
    And do you think we can solve the problem in this
    way?The DLL is going to be mapped into the process address space on first usage. More Java threads just means adding more references to the same DLL instance.
    That would not result in thread-safe behavior.

  • How can I use a Selector in a thread safe way?

    Hello,
    I'm using a server socket with a java.nio.channels.Selector contemporarily by 3 different threads (this number may change in the future).
    From the javadoc: Selectors are themselves safe for use by multiple concurrent threads; their key sets, however, are not.
    Following this advise, I wrote code in this way:
             List keys = new LinkedList(); //private key list for each thread
             while (true) {
              keys.clear();
              synchronized(selector) {
                  int num = selector.select();
                  if (num == 0)
                   continue;
                  Set selectedKeys = selector.selectedKeys();
                  //I expected this code to produce disjoint key sets on each thread...
                  keys.addAll(selectedKeys);
                  selectedKeys.clear();
              Iterator it = keys.iterator();
              while (it.hasNext()) {
                  SelectionKey key = (SelectionKey) it.next();
                  if ((key.readyOps() & SelectionKey.OP_ACCEPT) == SelectionKey.OP_ACCEPT) {
                   Socket s = serverSocket.accept();
                   SocketChannel sc = s.getChannel();
                   sc.configureBlocking( false );
                   sc.register( selector, SelectionKey.OP_READ );
                  } else if ((key.readyOps() & SelectionKey.OP_READ) == SelectionKey.OP_READ) {
    //.....Unfortunately synchronizing on the selector didn't have the effect I expected. When another thread select()s, it sees the same key list as the other thread that select()ed previously. When control arrives to serverSocket.accept(), one thread goes ahead and the other two catch an IllegalBlockingModeException.
    I'm not willing to handle this exception, the right thing to do is giving disjoint key sets to each thread. How can I achieve this goal?
    Thanks in advance

    A single thread won't be enough cause after reading data from the socket I do some processing on it that may take long.So despatch that processing to a separate thread.
    Most of this processing is I/O boundI/O bound on the socket? or something else? If it's I/O bound on the socket that's even more of a reason to use a single thread.
    Anyway I think I'll use a single thread with the selector, put incoming data in a queue and let other 2 or 3 threads read from it.Precisely. Ditto outbound data.
    Thanks for your replies. But I'm still curious: why is a selector thread safe if it can't be used with multiple threads because of it's semantics?It can, but there are synchronization issues to overcome (with Selector.wakeup()), and generally the cost of solving these is much higher than the cost of a single-threaded selector solution with worker threads for the application processing.

  • How to make the main() thread wait?

    I would like to know how to make the main() thread wait for another thread?If I use wait() method in main() method it says "non-static method wait() cannot be referenced from a static context",since main()
    is static.

    Here is an example how you may wait for a Thread in the main -
    but be careful, this is no real OO:
    public class WaitMain {
    // this is the thread class - you may also create
    // a runnable - I use a inner class to
    // keep my example simple
         public static class ThreadWait extends Thread{
              public void doSomething(){
                   synchronized(syncObject){
                        System.out.println("Do Something");
                        syncObject.notify();
              public void run(){
                   // sleep 10 seconds - this is
                   // a placeholder to do something in the thread
                   try{
                        sleep(10000);
                        doSomething();
                        sleep(10000);
                   catch(InterruptedException exc){
    // this is the object we wait for -
    // it is just a synchronizer, nothing else
         private static Object syncObject = new Object();
         public static void main(String[] args) {
              System.out.println("This will start a thread and wait for \"doSomething\"");
              ThreadWait t= new ThreadWait();
              t.start();
              synchronized(syncObject){
                   try{
    // this will wait for the notify
                        syncObject.wait();
                        System.out.println("The doSomething is now over!");
                   catch(InterruptedException exc){
              // do your stuff

  • 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.

Maybe you are looking for

  • My dad just got the new MacBook for Christmas. His friends all use PC's....

    My dad just got the new MacBook for Christmas. His friends all use PC's and they keep sending him these joke email attatchment files that he can't open on his Mac. One was a .wma audio file, presumably some were video files. Is it possible for him to

  • Restore and recover Oracle 10g database from tape.

    I have a very basic question for restore and recover Oracle 10g database. Our envirnment settings are: Oracle 10g on Unix, daily database and archivelog backup to Vista NetBackup server. Retention policy is 2. Old backup files are copied from NetBack

  • NAMM show report

    I was at the NAMM show on thursday. Apple was showing Logic version 7.2 it's the universal binary version the will run on both intel macs and power macs. They fixed up some things. 1. Worked with Digidesign to get Logic to work better with Digi hardw

  • Bridge freezes up

    bridge is freezing up.  Win7.  installed latest upgrades etc.  never happened before

  • Adobe photoshop elements 11 "editor"

    Organzier doesn´t copy picture into Editor, Why? If i open the Editor the picture does not open in Editor view. Thx for the Help.