SwingWorker JavaDB Concurrency problems

I have an application that computes statistics from values stored in a JavaDB database. I am trying to implement batch job functionality that will allow users to quickly run multiple analyses without the point-and-click of the GUI. Each analysis extends SwingWorker, which adds text to a JTextArea when the done() method is called. My problem is that I get a "java.sql.SQLException: No suitable driver found for jdbc:derby:C:/mydatabase" SQL exception sometimes. the code below illustrates my problem. I'm guessing that this is a concurrency issue, but I don't know how to fix it. Any suggestion?
The GUI class is:
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class MyGui extends JFrame{
     private static final long serialVersionUID = 1L;
     JTextField text = null;
     JPanel main = null;
     String connectionString = "jdbc:derby:C:/mydatabase";
     String tableName="MYTABLE";
     String selectStatement = "SELECT * FROM " + tableName;
     public MyGui(){
          super("Concurrency Test");
          this.setPreferredSize(new Dimension(300,100));
          getContentPane().add(getPanel());
     public JPanel getPanel(){
          JPanel main = new JPanel();
          main.setLayout(new GridLayout(1,1));
          text = new JTextField(30);
          text.setText("Start");
          main.add(text, BorderLayout.CENTER);
          return main;
     public void readDatabase(){     
          int count=0;
          for(int i=0;i<10000;i++){
               count++;
               try{
                    ConnectAndRead reader =  new ConnectAndRead(connectionString, selectStatement, text, count);
                    reader.execute();
               }catch(Exception ex){
     public static void main(String[] args) {
          MyGui gui = new MyGui();
          gui.pack();
          gui.setVisible(true);
          gui.setResizable(false);
          gui.readDatabase();
}And the Database connection class is:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JTextField;
import javax.swing.SwingWorker;
public class ConnectAndRead extends SwingWorker<String, Void>{
     String connectionString="";
     String selectStatement="";
     JTextField text=null;
     int count = 0;
     public ConnectAndRead(String connectionString, String selectStatement, JTextField text, int count){
          this.connectionString=connectionString;
          this.selectStatement=selectStatement;
          this.text=text;
          this.count=count;
     public String connectAndRead()throws SQLException{
          Connection conn = null;
          try{
               conn = DriverManager.getConnection(connectionString);
               Statement stmt=conn.createStatement(ResultSet.CONCUR_READ_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE);
               ResultSet rs = stmt.executeQuery(selectStatement);
               rs.close();
               stmt.close();
               conn.close();
               String text = "Database access " + count + "(should be 10,000)";
               return text;
          }catch(SQLException ex){
               count--;
               throw new SQLException(ex);
     protected String doInBackground() {
          String s = "";
          try{
               s = connectAndRead();
          }catch(SQLException ex){
               ex.printStackTrace();
          return s;
     @Override
     protected void done(){
          try{
               text.setText(get());
          }catch(Exception ex){
               ex.printStackTrace();
}

I believe I found the solution to my problem. It is posted here [http://forum.java.sun.com/thread.jspa?threadID=5298060&tstart=0] . Sorry for the cross posting.

Similar Messages

  • Concurrency Problem: Does it exist in following situation?

    Hi All
    Please consider the following problem:
    There are 100 systems connected through LAN. 99 systems have a tool in local drive that reads and writes certain files at 100th system.
    As the tool will work in local JVM, and each JVM will try to read & write the same file. is there any concurrency problem?
    OR
    i should ask how to solve this concurrency problem?
    Please provide your advice, suggestion or comments.
    --Azodious_                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    It means it's not possible without having a server? please answer.
    one more thing, if i have a server and doesn't use J2EE at all, is there goin to be some problem? can this be imlements using core java only.
    All JVM interacts with one JVM at server. is it a good idea?
    --Azodious_                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Session concurrency problems on using IFrame

    Hi All,
    I am working on internationalization , i've used session level for differnt languages . In a jsp page there is one IFrame
    when i opend jsp page for english, content of IFrame is also english
    But when i open arbic version simultaneously Content of IFrame are not arabic those are english.
    When i print the session ID inside IFrame then i found that sessionID are overlapped inside IFrame.
    But everything is working fine for outer jsp page.There is no concurrency problem.
    Note : I track this error while setting the page referesh time one second
    using meta tag.
    Please help me for this issue.If you need any code for that please tell me.
    Thanks & Regards
    Himanshu

    is the url of your iframe the same as your outer page?
    if your outer page is http://127.0.0.1 and the iframe is http://localhost, you will have 2 sessions

  • Concurrency problem

    Hi,
    If we have our logic of updating a balance in a table written in front end, there's possibility that 2 person may select and update at the same time.
    eg. balance is 100, and Mr.A wants to deduct 10, same as Mr. B.
    When Mr.A selects to read the balance then update, he reads 100, same as Mr. B.
    At the end, the balance will not be accurate.
    So, I am now shifting the logic for updating the balance to database triggers, will this solve the concurrency problems?
    Please advise.
    Thanks.

    Hi,
    Since I have my code written in trigger already, I don't really have the time to change it to select for update clause yet.
    What I need to know is if I put the following code in my trigger, will the database trigger take care of the concurrency issue?
    /* inside the trigger */
    select balance
    from mytable
    where mt_id = 100;
    update mytable
    set balance := balance - 10
    where mt_id = 100;
    Notice I don't have the for update clause in my trigger, is it ok? or the trigger will still face the concurrency problem only if I use for update even in trigger?
    Please advise.
    Thanks.

  • Thread concurrency problem - how to know when thread is dead?

    My applet uses a thread to draw an iteration graph step by step.
    The user as the option of pressing two buttons:
    - PLAY button - iteration Points are stored in an arrayList and drawn step by step (a sleeping time follows each step) (drawIterations thread)
    - TO_END button - iteration Points are all stored in the arrayList (swingworker thread) and after all of them have been stored the graph is drawn instantly.
    I have problems in this situation:
    When executing the PLAY-button thread, if the user presses TO_END button, the remaining graph lines should draw instantly. Sometimes I get more points on the graph than I should. It seems that the PLAY thread, which I stop when TO_END buton is pressed, still remains storing new points into the arrayList concurrently to the new thread created after TO_END button was pressed .
    Any ideas?
    I'm already using synchronization.
    private volatile Thread drawIterations;
    public void playButtonClick(JToggleButton btn) {
         pointSet1 = new ArrayList<Point2D.Double>();
         if (drawIterations == null) drawIterations = new Thread(this,   "drawIterations");
         drawIterations.start();
    public void toEndButtonClick(JToggleButton btn) {
         stopThread() ;
         pointSet1 = new ArrayList<Point2D.Double>();
         computeIterationGraphPointsAndRefreshGraph();
    public synchronized void stopThread() {
         drawIterations = null;
         notify();
    private void computeIterationGraphPointsAndRefreshGraphs() {
         SwingWorker worker = new SwingWorker() {
              public Object construct() {
                   // compute all iteration points
                         //repaint graph
         worker.start();
    }Is there a way of testing if a thread is actually dead after setting the thread object to null??

    In general, a Thread keeps running until it's run
    method completes. Threads don't stop when their
    handle is set to null. Your run method should
    constantly be checking on a variable to know when to
    stop running and exit the run method. In this case,
    you could check on the drawIterations variable to see
    if it's null.<br>
    <br>Even using the following line on my run method I get the the same problem:
    <br>
    <br>while (myThread == drawIterations && drawIterations!=null && halfStep < 2 * totalIterations) {
    <br>...
    <br>
    <br>Here's the whole method:
    <br>(actually there are 2 graphs being drawn and the second is only refreshed every 2 steps:)
    <br>
    <br>     <br>public void run() {
         <br>  Thread myThread = Thread.currentThread();
         <br>  int totalIterations = transientIterations +iterationsToDraw ;
              <br>  while (myThread == drawIterations && drawIterations!=null && halfStep < 2 * totalIterations) {
              <br>     computeNextHalfIterationGraphPoint( );
              <br>      if (!TRANSIENT_IS_ENABLED || halfStep >= 2*transientIterations ) {// is     not in transient calculations
              <br>                       graphArea1.repaint();
              <br>                       if (halfStep%2 ==0 ) graphArea2.repaint();
              <br>                       if (halfStep < 2*totalIterations){//no need to execute the following block if at last iteration point
                   <br>                         if (lastIterationPointsFallOutsideGraphArea(toEndCPButtonActive)) break;
                        <br>          try {
                             <br>                      Thread.sleep(sleepingTimeBetweenHalfIterationRendering);
                             <br>                      if (threadInterrupted ){//if clause included to avoid stepping into a synchronized block if unnecessary
                                  <br>                        synchronized (this) {
                                       <br>                          while (threadInterrupted && myThread==drawIterations ) wait();
                                                      <br>    }
    <br>                                               }
         <br>                                   } catch (InterruptedException e) {
              <br>                                     break;
                   <br>                         }     
                        <br>               }
    <br>                            }
         <br>        stopThread();
         <br>     }
    <br>

  • Regarding Receiver Communication Channel (Concurrency problem)

    Hi Masters ,
    In Receiver Communication Channel which is connected to oracle data base ..while updating records Status from N to C . i am getting following errors :
    **Message processing failed. Cause: com.sap.aii.af.ra.ms.api.RecoverableException: Channel has reached maximum concurrency (5,000 concurrent messages) and no free resource found within 5,000 milliseconds; increase the maximum concurrency level**
    Actually we are updating 10000 records status from N to C....... earlier it was updating in 30min now its hanging and giving above error ...... after 3 hrs its automatically displays updated succesfully message .
    Can you help me to understand wht exactly happening and at wht level i have to do settings in communication channel so tht it should work properly..
    Thanks in Advance.............
    Jagannath.

    Hi Jagannath
    you can specify the maximum concurrency for receiver adapters.  This defines the number of messages an adapter can process in parallel on a cluster node.
    Enter the number of messages to be processed in parallel by the receiver channel. For example, if you enter the value 2, then two messages are processed in parallel. Default value is 1 and this means only one message can be processed at a time by the receiver channel.
    http://help.sap.com/saphelp_nw70/helpdata/EN/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
    http://help.sap.com/saphelp_nw70/helpdata/EN/bc/bb79d6061007419a081e58cbeaaf28/frameset.htm
    increase this parameter from 1000 to a higher value you required and you would not be facing such problem
    Regards
    sandeep
    If helpful kindly reward points

  • Stored Procedure Concurrency Problem 10g

    dear all,
    Please any one could help on this my problem is appreciated.......
    i'm generating ticket numbers using stored procedure as below .
    i need to know followings .....(i'm using oracle 10g)
    1 .Does oracle stored procedure handle concurrency by default or does db manage concurrency when we using sps or do we have handle concurrency inside a stored procedure?
    2.when i generating ticket no using this stored procedure is there any concurrency issue when 100 clients are access it concurrently???
    3. Is there issue or bug in my java code??????????
    4.I have already used select for update statement but when i used that in db rowlocks are hanging and db become stuck .........
    SELECT serial_no into newSerial FROM SERIAL_TAB WHERE BR_CODE=xbranch AND SCH_CODE = xscheme for update;
    5. and in my where clause i pass branch and scheme eg:SELECT serial_no into newSerial FROM SERIAL_TAB WHERE BR_CODE=xbranch AND SCH_CODE =
    xscheme;
    when i run this sp oracle return the error 'more than one row return by query'
    but when run query seperately it will return exactly one row for same brach code and scheme code no duplicates.
    why this happen and it also happen to update statement it will ignore branch code and update for all schemes
    UPDATE SERIAL_TAB SET serial_no=newSerial WHERE BR_CODE=xbranch AND SCH_CODE = xscheme;
    what should i do ? sorry for my long question since i'm in deep trouble.....................
    could any one can help please................................
    in my java code i use transaction and setAutoCommit(false) when calling this sp
    public String getTicketNo(String br,String sch){
    //getconnection
    //setAutoCommit(False);
    //call sp get return value ;
    //commit;
    //if error rollback transaction
    create or replace PROCEDURE sp_generate_ticket (
    xbranch in varchar,
    xscheme in varchar ,
    xresult OUT VARCHAR
    ) AS
    BEGIN
    newSerial:=0;
    SELECT serial_no into newSerial FROM SERIAL_TAB WHERE BR_CODE=xbranch AND SCH_CODE = xscheme;
    newSerial:=newSerial+1;
    UPDATE SERIAL_TAB SET serial_no=newSerial WHERE BR_CODE=xbranch AND SCH_CODE = xscheme;
    --- do other operations -------------------------------------------------------------------------------------
    END;
    Best Regards,
    Pradeep.
    Edited by: user8958520 on Jan 1, 2012 10:02 PM

    user8958520 wrote:
    i need to know followings .....(i'm using oracle 10g)
    1 .Does oracle stored procedure handle concurrency by default or does db manage concurrency when we using sps or do we have handle concurrency inside a stored procedure?Oracle is a multi-user and multi-process system. It supports concurrency. It also requires the developer to design and write "+thread safe+" code. Its concurrency cannot address and fix design flaws in application code.
    2.when i generating ticket no using this stored procedure is there any concurrency issue when 100 clients are access it concurrently???That depends entirely on WHAT that procedure code does. And whether that code is thread safe.
    4.I have already used select for update statement but when i used that in db rowlocks are hanging and db become stuck .........
    SELECT serial_no into newSerial FROM SERIAL_TAB WHERE BR_CODE=xbranch AND SCH_CODE = xscheme for update;Horrible and utterly flawed approach. This forces serialisation. This means if that procedure is call by a 100 clients, only a SINGLE client can be serviced at a time. ALL OTHERS need to queue and WAIT.
    Serialisation kills database performance.
    What you have is a serious design flaw. Not an Oracle issue. And there is no magic solution to make this flawed approach work in a performant and scalable manner. This flaw introduces artificial contention. This flaw enforces serialisation. This flaw means that your application code WILL step on its own toes time and time again.
    The proper solution is to fix this design flaw - and not use poorly conceived procedures such as sp_generate_ticket that violates fundamental concurrency principles.

  • SwingWorker asynchronous PropertyChangeEvent problems

    I'm using a SwingWorker to execute a task that I am keeping progress on. I have a JDialog that I show and dispose of based on events from the SwingWorker. These events are generated asynchronously on the EDT which is fine. I understand that it may be the case I could call setProgress a few times before a PropertyChangeEvent actually happens, however what I don't understand is why a "state" event is never making it as the event when the SwingWorker completes. If I cancel the task it will reach it, but when it finishes by itself there is nothing. This state event should be getting fired and listened to and handled on the EDT but its not. Attached is my code for three classes and an example of how to use it. Basically it just takes a .lst whose format is an IP address on each line, nothing else.
    public class OpenSwingWorker extends SwingWorker<Object[], Object> {
        private FILETYPE _fileType = null;
        private File[] _files = null;
        private DefaultListModel _listModel = null;
        private List<Object> _objects = null;
        private int _progress = 0;
        public OpenSwingWorker(FILETYPE fileType, File[] files, ListModel listModel) {
            _fileType = fileType;
            _files = files;
            _listModel = (DefaultListModel) listModel;
            _objects = new ArrayList<Object>();
        @Override
        protected Object[] doInBackground() {
            int progress = 0;
            if (_fileType == FILETYPE.LST) {
                BufferedReader bufferedReader = null;
                String line = null;
                for (File file : _files) {
                    if (isCancelled()) {
                        break;
                    try {
                        bufferedReader = new BufferedReader(new FileReader(file));
                        while ((line = bufferedReader.readLine()) != null) {
                            InetAddress inetAddress = InetAddress.getByName(line);
                            _objects.add(inetAddress);
                            publish(inetAddress);
                    } catch (FileNotFoundException ex) {
                        Logger.getLogger(OpenSwingWorker.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (IOException ex) {
                        Logger.getLogger(OpenSwingWorker.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (Exception ex) {
                        Logger.getLogger(OpenSwingWorker.class.getName()).log(Level.SEVERE, null, ex);
                    } finally {
                        try {
                            bufferedReader.close();
                        } catch (IOException ex) {
                            Logger.getLogger(OpenSwingWorker.class.getName()).log(Level.SEVERE, null, ex);
                    setProgress(++_progress * 100 / _files.length);
            } else if (_fileType == FILETYPE.MSG) {
                MsgParser msgParser = Main.getMsgParser();
                for (File file : _files) {
                    if (isCancelled()) {
                        break;
                    try {
                        MessageRecord messageRecord = new MessageRecord(msgParser.parseMsg(file));
                        _objects.add(messageRecord);
                        publish(messageRecord);
                    } catch (IOException ex) {
                        Logger.getLogger(OpenSwingWorker.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (UnsupportedOperationException ex) {
                        Logger.getLogger(OpenSwingWorker.class.getName()).log(Level.SEVERE, null, ex);
                    setProgress(++progress * 100 / _files.length);
            return _objects.toArray();
        @Override
        protected void process(List<Object> chunks) {
            for (Object object : chunks) {
                _listModel.addElement(object);
    public class SwingWorkerPropertyChangeListener implements PropertyChangeListener {
        private ProgressJDialog _progressJDialog = null;
        private SwingWorker _swingWorker = null;
        public SwingWorkerPropertyChangeListener(ProgressJDialog progressJDialog, SwingWorker swingWorker) {
            _progressJDialog = progressJDialog;
            _swingWorker = swingWorker;
        public void propertyChange(PropertyChangeEvent evt) {
            String propertyName = evt.getPropertyName();
            if (propertyName.equals("state")) {
                SwingWorker.StateValue stateValue = (StateValue) evt.getNewValue();
                if (stateValue.equals(SwingWorker.StateValue.STARTED)) {
                    _progressJDialog.setVisible(true);
                } else if (stateValue.equals(SwingWorker.StateValue.DONE)) {
                    _progressJDialog.dispose();
            } else if (propertyName.equals("progress")) {           
                if (_progressJDialog.isCancelled()) {
                    _swingWorker.cancel(true);
                } else {
                    _progressJDialog.setProgress((Integer) evt.getNewValue());
    public class ProgressJDialog extends JDialog {
        private boolean _cancelled = false;
        private JButton _jButton = null;
        private JProgressBar _jProgressBar = null;
        public ProgressJDialog(boolean indeterminate, String taskName) {
            super((JDialog) null, "Performing Task...", true);
            _jProgressBar = new JProgressBar();
            _jProgressBar.setBorder(BorderFactory.createTitledBorder(taskName));
            _jProgressBar.setIndeterminate(indeterminate);
            _jProgressBar.setStringPainted(true);
            initComponents();
        private void createJButton() {
            _jButton = new JButton("Cancel");
            _jButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    dispose();
            _jButton.setMnemonic(KeyEvent.VK_C);
        private void initComponents() {
            createJButton();
            add(_jProgressBar, BorderLayout.CENTER);
            add(_jButton, BorderLayout.LINE_END);
            addWindowListener(new WindowAdapter() {
                @Override
                public void windowClosed(WindowEvent e) {
                    _cancelled = true;
            pack();
            setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        public boolean isCancelled() {
            return _cancelled;
        public void setProgress(int progress) {
            _jProgressBar.setValue(progress);
    /* EXAMPLE USAGE BELOW */
    if (jFileChooser1.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
                SwingWorker openSwingWorker = new OpenSwingWorker(Main.FILETYPE.valueOf(jFileChooser1.getFileFilter().getDescription()), jFileChooser1.getSelectedFiles(), jList1.getModel());
                openSwingWorker.addPropertyChangeListener(new SwingWorkerPropertyChangeListener(new ProgressJDialog(false, "Opening files..."), openSwingWorker));
                openSwingWorker.execute();
    }

    I figured out the problem. It's not that the PropertyChangeEvent's weren't occuring it's that they were occuring too quickly. I placed a sleep before setting progress and now it works nicely. I hope if anyone else runs into this problem I save them some time this was bugging me forever. Thanks again.

  • After 10.6.5 upgrade: airport concurrency problems (e.g. streaming+surfing)

    Hi!
    Since I upgraded to 10.6.5 I've got a serious airport problem: It seems as I can only have 1 TPC/UPD connection at a time. At least several programs accessing the internet at the same time somehow show a strange behaviour:
    For example when I listen to a music stream in iTunes I can't access "new" internet sites. It looks like the browser can't send the DNS request. When I open a shell and do an "nslookup" and then copy+paste the IP into the browser, it works (but somehow slow). When I stop the music stream, everything is immediately fine again.
    When downloading large files, Apple mail says the mail server couldn't be contacted. When having a teamviewer session, I can't open websites... and so on.
    The problem only occurs when I'm connected over Airport. The connection itself is good and fast, several other devices (iPad, iPod, PC) can use the same router without any problems.
    When I use a network cable, everything works fine. Then, when disconnecting the cable, surfing+streaming via Airport somehow seems fine, too. But after several minutes it becomes slow/unusable again. (looks like a cache/stack/buffer somehow runs full...)
    I've already tried out this:
    - removing airport and all other connections
    - removing some network related .plist files
    - installing the combo update again
    - weaker or no airport encryption
    - another router
    - another DNS
    - another year
    Unfortunately I noticed the behaviour after some weeks of work without music streams or large concurrent downloads, so my last 10.6.4 backup has meanwhile been overwritten.
    Please help getting my airport to work fine again. Thx in advance!
    Many greetings
    Daniel P.

    Try another DNS in your System Preferences->Network pane, highlight the Airport card, in the right-hand pane click on the 'Advances' button. In the drop-down click on the DNS tab and experimenting using the DNS server OpenDNS.com. See if using their DNS (they have a instructional video on how to use it) helps your situation.

  • Will my servlet have concurrency problems?

    i am deploying a servlet on Tomcat 4.0. This servlet creates objects or uses some session objects. It also temporarily stores data in a String object in the servlet.
    Will i have problems with concurrent users?
    If so, how can i set up Tomcat to use more than one Servlet instance?

    Actually, it is possible (and likely) that the same session will be accessed by competing, multiple requests. This is possible if the user opens multiple windows accessing your site, clicks on links/presses reload while pages are loading, or if you have multiple frames. According to section 7.7.1 of the Servlet API Specification, it is the developer's responsibility to synchronize accesses to session resources.

  • Concurrency problem in Servlets, JSP

    Hi all
    I found that whenever 2 or more access my servlet or jsp, the server is giving an error.
    How do I solve this. How do I synchronize.
    Please help.
    Rajani

    You do know that once instantiated, a servlet object is used to service requests from multiple(and concurrent) clients. Right ?
    Well then, the first thing to check is whether you have any instance data members in your servlet classes or your JSPs.

  • Thread Concurrency problem

    Hello
    i have an application where i have about 6 threads....I have each of this thread working independently ..i.e each thread has its publis static main method.....they are continuously running..... and they are working correctly.... but the problem is that i have run each thread explicitly....
    But now i want to combine all these threads into one thread so that when i run my java application all these threads will start running.....I tried doing it but the problem is that the first thread itself runs...the other threads do not run...... how do i do this????
    The code of the program where i clubbed the threads is
    public class MainThread
    public static void main(String arg[])
    NewThread n= new NewThread() ;
    System.out.println("in psvm") ;
    class NewThread extends Thread
    String name; // name of thread
    Thread t;
    NewThread()
    System.out.println("in newthread") ;
    SMSSendThread sms=new SMSSendThread() ;
    UsernameThread user=new UsernameThread() ;
    user.start() ;
    SendInbox inbox=new SendInbox() ;
    inbox.start() ;
    DeleteSMS delete=new DeleteSMS() ;
    delete.start();
    My start method of each of these thread contains ie.deleteSMS,SendInbox
    public void start()
    HashSet<Socket> clients = new HashSet<Socket>() ;
    try
    Boolean listening=true ;
    ServerSocket ss=new ServerSocket(2345) ;
    Socket socket=new Socket() ;
    int id=0;
    while(listening)
    System.out.println("Detecting Client please Wait in send thread:=") ;
    socket = ss.accept();
    clients.add(socket);
    System.out.println("clients display:="+clients) ;
    if(clients.contains(socket))
    InetAddress clientIP=socket.getInetAddress() ;
    System.out.println("the ip addrss of the client:="+clientIP) ;
    new ConnectionHandlerdelete(socket).start() ;
    The problem is that only the Username thread exceutes priopely the other two are not running!!!!

    Then why are the other threads not runningIf that is your code you are mistaken about this.
    > the newthread class runs as it is supposed to
    The newthread class constructor runs as it is supposed to , and it starts the other threads. You never call start on it so it never executes its run() method. It doesn't even appear to have a run() method.
    So either this is not your real code or your observations are mistaken.

  • Agile PLM Concurrency Problem

    Hi,
    We have a URL based Process Extension that basically sets three multi list attributes through out the BOM structure of an item based on the values selected by the user in UI. When two users trigger the PX on the same item at the same time or on different items with common BOMs, we are encountering the below problem:
    1. PX picks up the first user’s thread, gets the already present selection on the multi list , adds the values user selected to the existing selection and sets all the values on the multi list attribute.
    2. Meanwhile, PX picks up the second user’s thread, who is also trying to set values on the same multi list value. Here we are refreshing the object and getting the already present selection for the multi list on the object. At this point, instead of giving the value which was set by the first user, it gives the old value which was present initially when the PX got triggered (not giving the latest value from the existing selection of the multi list).
    In the above scenario, SDK is not throwing any exception and results in bad data. We checked Agile API and there is no function to lock Agile object. Has anyone faced similar kind of problem? If so can you share your inputs on resolving the issue. Thank you.
    Edited by: user13542521 on Aug 29, 2011 11:58 AM

    I also replied to your other posting. I am a product manager on the Agile team. At this time, we are using the Support Communities page as a discussion forum rather than the OTN discussion forums. Please repost into the Support (Metalink) Communities area.
    Other options include the Yahoo group WRAU and reviewing the PLM blog at http://blogs.oracle.com/PLM.
    Thanks.

  • Concurrent problem-can any one give idea 4 my assignment?

    Create a GUI program to trace out any braces and keep track of the line having wrong closure of any
    braces dynamically and identify the previous line typed if error prone note some red symbol in the
    marigin. The marigin however must dynamically increase the line count of the coding.
    can any one give idea 4 my assignment?

    Providing any solution for your task makes no sense to anyone here. You need to manage your assignment, so start with it. Do not waist time asking somebody else to do your work!
    Start! Go to work! Now!
    Any specific questions you need to ask on your way can be answered here.

  • A question about concurrency and static getter methods

    Hello
    I have a class with some static methods. they just return a reference and doesnt apply any changes.
    something like this:
    public class FieldMapper {
            private static Map<Class,Map<String,String>> fieldMap = new HashMap<Class,Map<String,String>>();
            public static getFields(Class clazz){
                  return fieldMap.get(clazz);
    }my question is, let's consider many users connect to my server and each has its own session, now assume one user want to use FieldMapper.getFields(User.class) and another is going to call FieldMapper.getFields(Employee.class) at same time or a bit milli seconds after, and this method is not synchronized, is there any conflict in calling the method? would this method return wrong reference to the first invocation?
    in genereal, may the concurrency make problem on reading resources? or just on changing resources?
    Thank you very much in advance.

    To publish an object safely, both the reference to the object and the object's state must be made visible to other threads at the same time. A properly constructed object can be safely published by:
    Initializing an object reference from a static initializer;
    Storing a reference to it into a volatile field or AtomicReference;
    Storing a reference to it into a final field of a properly constructed object; or
    Storing a reference to it into a field that is properly guarded by a lock. The internal synchronization in thread-safe collections means that placing an object in a thread-safe collection, such as a Vector or synchronizedList, fulfills the last of these requirements. If thread A places object X in a thread-safe collection and thread B subsequently retrieves it, B is guaranteed to see the state of X as A left it, even though the application code that hands X off in this manner has no explicit synchronization.
    Now in the case you have specified you are using HashMap. Which is not designed to be threadsafe as opposed to HashTable or concurrentHashMap. In such a case I would advise against using this. The concurrency problem is caused by race conditions on mutable objects, whether it is reading or writing. If it is mutable, it is susceptible to race conditions. IMHO
    &spades;

Maybe you are looking for

  • Best way to connect iPod to LCD monitor?

    Hello, I wish to hookup my 5G iPod to a LCD monitor to display a slide show. I know that some LCD's have RCA inputs (the yellow one) or S Video inputs and can thus go straight from the iPod. But many economy model LCD's do not have these. So how can

  • Using href in a JSP

              Hi there           I'm using to call KopfDatenJSP.jsp from another JSP, located in the package           TD/filename.jsp           DCL is the name of the application.           WLS is able to find KopfDatenJSP.jsp but its images are not dis

  • Editing multiple objects

    Pretty simple question, How to I edit multiple objects from their individual centre points? Cheers -Ford

  • Non US date string format

    I have csv files (many) with time stamped data in the format ddmmyyyy (and yymmdd). I seem unable to tell Diadem what format to expect and it seems to assume the US format mmddyyyy is good enough!. Short of reformatting all my data time stamps can't

  • Can't sync my ipod even when uncheck memo

    i i try every tips you've said, but every time i try to uncheck memovoice, the itunes block and windows close itunes.now, i still haven't sync my ipod Any other tips? thanks