Can't display the right charachter into a JTextField

When I try to print the letters consumed by a consumer into the JTextField "consumer1" it just wont do it. Only if I type "return "A" as below.
I've marked the important places with //---------------->>>>>
A cut from class Gui
public static JTextField consumer1;
     public static void addText(String cId) {
          Object a = Consumer.getConsumedItem(cId);
          consumer1.setText(a.toString());
Class Consumer
import java.awt.event.ActionEvent;
import java.util.List;
import java.util.Vector;
public class Consumer implements Runnable {
     public Thread consumer = new Thread(this);
     public long DELAY = 0;
     private Buffer buf;
     private String text;
     private CharacterFactory cf;
     private static List<Object> hasConsumedC1 = new Vector<Object>();
     private static List<Object> hasConsumedC2 = new Vector<Object>();
     private static List<Object> hasConsumedC3 = new Vector<Object>();
     private String consumerId;
     public Consumer(String txt, long del, Buffer b, String cId) {
          text  = txt;
          DELAY = del;
          buf = b;
          consumerId = cId;
     public void run ()    {
          while (true) {
               try {
                    System.out.println("WAITING_ON_BUFFER_ACCESS");
                    if (buf.emptyBuffer())
                         System.out.println("WAITING_ON_BUFFER_NOT_EMPTY");
                    else {     
                         System.out.println("MANIPULATING_BUFFER");
                         System.out.println(buf.take(consumerId));
                         System.out.println("CONSUMING");
                         System.out.println("Tr�den " + this.consumerId + " har f�rdr�jningen " + DELAY + " sekunder");
                         Thread.sleep(DELAY);
               catch (InterruptedException e) {
//---------------->>>>>
          Gui.addText("c1");
//---------------->>>>>
     public void setDelayTime(int i){
          this.DELAY = i*1000;
          System.out.println(DELAY);
     public static void hasConsumed(Object obj, String cId){
          if (cId == "c1")
               hasConsumedC1.add(obj);
          else if (cId == "c2")
               hasConsumedC2.add(obj);
          else if (cId == "c3")
               hasConsumedC3.add(obj);
          public static Object getConsumedItem(String cId) {
//---------------->>>>>     
     if (cId == "c1")
               return ("A");
          //return (hasConsumedC1.get(0));     This is what I want it to do!
//---------------->>>>>     
          else if (cId == "c2")
               return (hasConsumedC2.get(0));
          else if (cId == "c3") {
          return (hasConsumedC3.get(0));
From buffer
public synchronized Object take(String cId){
          while (buffer.isEmpty())
               try
                    wait(DELAY);
          catch (InterruptedException e){
               return null;
          Object obj = buffer.get(0);
          buffer.remove(0);
//---------------->>>>>          
     Consumer.hasConsumed(obj, cId); //Here I put the consumed item into Consumer method hasConsumed
//---------------->>>>>     ------------------------------------------------------------------------------------------------------------------------------

Hi,
Yes now I understand what you want to do, but I think you are doing it in a bad way. What will you do if you have 50 consumers? You should instead do something similar to this (note that it doesn't solve your homework you still have to implement some parts):
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
public class CharacterSoup {
     public static void main(String[] args) throws Exception {
          Queue<Character> queue = new ConcurrentLinkedQueue<Character>();
          Queue<ExecutionReport> reports = new ConcurrentLinkedQueue<ExecutionReport>();
          new Thread(new Consumer("thread1", queue, reports)).start();
          new Thread(new Consumer("thread2", queue, reports)).start();
          for (int i = 'a'; i<= 'z'; i++) {
               synchronized (queue) {
                    Character ch = Character.valueOf((char)i);
                    System.out.println("Main thread is offering " + ch);
                    queue.offer(ch);
                    queue.notifyAll();
               Thread.sleep((long)(3000 * Math.random()));
          //TODO create a thread consumes from reports, and populates ui
class Consumer implements Runnable {
     private String id;
     private Queue<Character> buffer;
     private Queue<ExecutionReport> reports;
     public Consumer(String id, Queue<Character> buffer, Queue<ExecutionReport> reports) {
          this.buffer = buffer;
          this.reports = reports;
          this.id = id;
     public void run() {
          try {
               Character ch = null;
               while (true) {
                    synchronized (buffer) {
                         while (buffer.isEmpty()) {
                              buffer.wait();
                         ch = buffer.poll();
                    synchronized (reports) {
                         System.out.println(id + " added report for " + ch);
                         reports.offer(new ExecutionReport(id, ch));
                         reports.notifyAll();
          } catch (InterruptedException e) {
               e.printStackTrace();
class ExecutionReport {
     public String id;
     public Character ch;
     public ExecutionReport(String id, Character ch) {
          this.id = id;
          this.ch = ch;
}Kaj

Similar Messages

  • Trying to reset my password (which I have forgot) for elements 13 I have the serial no.  But I can't find the right website to reset? I have "copy & paste " into the browser.

    trying to reset my password (which I have forgot) for elements 13 I have the serial no.  But I can't find the right website to reset? I have "copy & paste " into the browser.

    Go to the main page of adobe.com and sign out if you're already signed in there. Then click Sign In at the upper right of the page. In the next page you will see a Forgot Password link:

  • Re: Satellite A660-12P - can't find the right display driver for Win XP

    Hey everyone, i need some help with this one:
    I just made a dual boot Win7 (x64)/XP (x86) on my laptop, but i can't find the right display drivers for the video controller VGA compatible on XP.
    Does someone know where i can find them?
    Many thanks,

    Yes, you get this message because you cannot install the nVidia rivers only executing the exe file.
    If you want to install such drivers then you have to do this in device manager.
    You have to force the notebook to choose the driver
    You can do this choosing the advanced installation procedure which helps you to point to the driver files!
    PS: might be helpful:
    http://forums.computers.toshiba-europe.com/forums/ann.jspa?annID=78

  • How can I display the rows into columns.

    How can I display the rows into columns. I mean
    Create table STYLE_M
    (Master varchar2(10), child varchar2(10));
    Insert itno style_m
    ('MASTER1','CHILD1');
    Insert itno style_m
    ('MASTER2','CHILD1');
    Insert itno style_m
    ('MASTER2','CHILD2');
    Insert itno style_m
    ('MASTER3','CHILD1');
    Insert itno style_m
    ('MASTER3','CHILD2');
    Insert itno style_m
    ('MASTER3','CHILD3');
    Note : The Master may have any number of childs.
    I want to display like this..
    Master child1, child2, child3, .......(dynamic)
    MASTER1 CHILD1
    MASTER2 CHILD1 CHILD2
    MASTER3 CHILD1 CHILD2 CHILD3
    Sorry for disturbing you. Please hlp me out if you have any slution.
    Thanks alot.
    Ram Dontineni

    Here's a straight SQL "non-dynamic" approach.
    This would be used if you knew the amount of children.
    SELECT
         master,
         MAX(DECODE(r, 1, child, NULL)) || ' ' || MAX(DECODE(r, 2, child, NULL)) || ' ' || MAX(DECODE(r, 3, child, NULL)) children
    FROM
         SELECT
              master,
              child,
              ROW_NUMBER() OVER(PARTITION BY master ORDER BY child) r
         FROM
              style_m
    GROUP BY
         master
    MASTER     CHILDREN                        
    MASTER1    CHILD1                          
    MASTER2    CHILD1 CHILD2                   
    MASTER3    CHILD1 CHILD2 CHILD3             Since you said that the number of children can vary, I incorporated the same logic into a dynamic query.
    SET AUTOPRINT ON
    VAR x REFCURSOR
    DECLARE
            v_sql           VARCHAR2(1000) := 'SELECT master, ';
            v_group_by      VARCHAR2(200)  := 'FROM (SELECT master, child,  ROW_NUMBER() OVER(PARTITION BY master ORDER BY child) r FROM style_m) GROUP BY master';
            v_count         PLS_INTEGER;
    BEGIN
            SELECT
                    MAX(COUNT(*))
            INTO    v_count
            FROM
                    style_m
            GROUP BY
                    master;
            FOR i IN 1..v_count
            LOOP
                    v_sql := v_sql || 'MAX(DECODE(r, ' || i || ', child, NULL))' || ' || '' '' || ';
            END LOOP;
                    v_sql := RTRIM(v_sql, ' || '' '' ||') ||' children ' || v_group_by;
                    OPEN :x FOR v_sql;
    END;
    PL/SQL procedure successfully completed.
    MASTER     CHILDREN
    MASTER1    CHILD1
    MASTER2    CHILD1 CHILD2
    MASTER3    CHILD1 CHILD2 CHILD3I'll point your other thread to this one.

  • Strange scenario,Oracle can not display the data in mysql correctly

    I use Heterogeneous Service+ODBC to achieve "oracle access mysql"(any other method?),and now i find Oracle can not display the data in mysql correctly:
    -------mysql------------
    mysql> create table tst(id int,name varchar(10));
    Query OK, 0 rows affected (0.00 sec)
    mysql> insert into tst values(1,'a');
    Query OK, 1 row affected (0.00 sec)
    mysql> select * from tst;
    ------------+
    | id | name |
    ------------+
    | 1 | a |
    ------------+
    1 row in set (0.00 sec)
    mysql> show create table tst\G
    *************************** 1. row ***************************
    Table: tst
    Create Table: CREATE TABLE `tst` (
    `id` int(11) DEFAULT NULL,
    `name` varchar(10) DEFAULT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8
    1 row in set (0.00 sec)
    -------------oracle ------------------
    SQL> select count(*) from "tst"@mysql;
    COUNT(*)
    49
    SQL> select * from "tst"@mysql;
    id
    1
    SQL> desc "tst"@mysql;
    Name Null? Type
    id NUMBER(10)

    You can make the following query on the result page:
    "select * from the_table where movietitle = ? and cinema = ?"
    then you set movietitle and cinema to those which the user selected. If the resultset contains more than 0 rows, that means the movie is available.
    Below is the sample code, it assumes you have a connection to the database:
    PreparedStatement stat = myConnection.prepareStatement("select * from the_table where movietitle = ? and cinema = ?");
    stat.setString(1, usersMovieTitleSelection);
    stat.setString(2, usersCinemaSelection);
    ResultSet res = stat.executeQuery();
    if (res.next()) {
    out.print("The movie is available");
    } else {
    out.print("The movie is not available");
    }Now just add that to your JSP page. Enjoy ! =)

  • Can't locate the right iPhoto Library

    I have a friend who can't find the right iPhoto Library.  Mac OS X 10.7 or 8...  latest iPhoto.  Searching in Finder for "iPhoto Library" produces no results, even though we see an iPhoto Library item in her Pictures folder (not the right one).
    So this leads me to believe that for some reason Finder won't display that....not sure why it would do that...but anyway.  She's a professional photographer, and doesn't know the name of most of the photos, because they are photos name by the camera.  She tried to find some with just the .jpg extension but everything was email or web based results that we found.  Thousands upon thousands.  This has happened before, and it was fixed, but we can't remember how. 
    Any help on how to locate the right version would be great.  Also, her Time Machine only seems to have the same one as in Pictures.  I think the iPhoto Library she uses is located somewhre else on the drive. 
    I also tried Locate and Find in the terminal, but neither brought up anything.
    Thanks in advance.

    Download and use  Find Any File to search for "Library6.iPhoto" which is a file in every iPhoto Library.  If there's another library on your hard drive FAF will find it as it can search areas that Spotlight can't.
    OT

  • BPM Workspace can't display the flash movie with IE

    Hi
    We have the following problem, we have a BPM project with a flash screen, when we execute the project in the workspace of BPM studio we can see the Flash, but when we published the project in BPM Enterprise , the workspace can't display the flash movie, it just display the panel without buttons and fields. This happen just in Internet Explorer, in other browsers we can see the flash.
    Any idea or solution ??
    Thanks in advance

    Actually, I got it working now...
    It seems that I have to have all the files in the same folder
    as the page it displays on!
    Historically I would dump a standard flash clip (not a
    converted movie with buttons) into the /images folder.
    I tested this intitally in a /video folder (just to keep all
    the files in one place) which would display the clip but not the
    buttons but as soon as I moved the files in the same directory as
    the page itself (which is the main index.html) it worked fine!
    So if anyone does read this is there a reason for that as I
    would like to keep everything in separate folders!
    Cheers, J

  • I deleted my ibooks author file but the preview is still available on my ipad, can I get the ibook back into ibooks author to continue to edit?

    I deleted my ibooks author file but the preview is still available on my ipad, can I get the ibook back into ibooks author to continue to edit? I have not published anything, just previewed on my ipad but the file seems to be deleted from my imac which is what I was using ibooks author on. Any help is welcome!

    It's not a 'process' at all.
    If it was easy/straightforward, people would be turning store versions into iBA versions left/right and all **** would break loose. It's not and that's a good thing, sorry
    Work up from whatever version you have.
    Any work you value should be backed up....period. That backup should be used and tested regularly. Consider this a lesson learned, perhaps. Good luck in the future.

  • How can  i  display the Number  instead of  E

    Hello Everyone ;
    I am getting confused. How can i display the Number but the Exponential value is coming as E.
    SQL> select sum(amount_sold) from sales;
    SUM(AMOUNT_SOLD)
    1.1287E+11
    Table details ..
    SQL> desc sales
    Name                                          Null?        Type
    AMOUNT_SOLD NUMBER
    i want to change 1.1287E+11 to "numeric"
    DB : 10.2.0.4
    os : rhel 5.1

    Just a minor correction on an obvious math/responding too fast error: 1.1287E+11 is a 12 digit number. You move the decimal 11 positions to the right which would add 7 zeroes to the value.
    MPOWEL01> l
      1  select length(to_char(1.1287E+11)), to_char(1.1287E+11,'999,999,999,999'), 1.1287E+11 "TEST"
      2* from sys.dual
    MPOWEL01> col TEST format 999999999999
    MPOWEL01> /
    LENGTH(TO_CHAR(1.1287E+11)) TO_CHAR(1.1287E+          TEST
                             12  112,870,000,000  112870000000the problem was that the OP failed to alias the sum result to the formatted column rather than the lenght of the data.
    HTH -- Mark D Powell --

  • How can i display the login details in the Web Ui

    Hi All,
              How can i display the information regarding the person who logged into the Web Ui and where can i find the seetings regardin this.Please provide your valuable suggestions
    Regrads,
    Lakshman.P

    look at this link https://wiki.sdn.sap.com/wiki/display/CRM/WelcomeUserMessageinWeb+UI and you will solve your problem.
    have a nice day.

  • Item supply/demand can't display the po_line that need-by is  multiple

    item supply/demand can't display the po_line that need-by is  multiple,i means that if the po_line have multi line_locations ,it can't be displayed in the supply/demand windows.
    how to deal this problem?

    To add detail to Mikeyc7m's last post
    If the folder has a default value for author then only an adminstrator could check files into that folder. This is because non administrators can not spoof their user name to be someone else's. With the default value being someone else they will never be able to check in (unless they are an admin who can spoof who the user is and in this case it will look like the user checked in a file and not the admin which is a different problem but still a problem).

  • Where can I find the right LIB_DBSL.SAR??

    hi all,
        I want to connect to the other DBMS.The detail is: my BI application server DBMS is oracle, it  runs on linux,64 bit,and the target DBMS is MSS 2000.
        The question is where can I  find the right LIB_DBSL.SAR,could you give me a link address?
        Thx..

    Hi,
    You need to log in to  service marketplacewith S userID& password. After logging into SMP, we need to find the relevant Database to find the Shared libraries that is LIB_DBSL.SAR file & then need to unarchive in order to load the DB dependent shared libraries.
    Regards
    Venkat

  • Kids have disabled iPad now I can't put the right passcode in.I do not have a laptop anymore.

    Kids have disabled iPad and I can't put the right passcode in.I don't have laptop anymore.Will it give me chance to put it in?

    iOS: Device disabled after entering wrong passcode
    http://support.apple.com/kb/ht1212
    How can I unlock my iPad if I forgot the passcode?
    http://tinyurl.com/7ndy8tb
    How to Reset a Forgotten Password for an iOS Device
    http://www.wikihow.com/Reset-a-Forgotten-Password-for-an-iOS-Device
    Using iPhone/iPad Recovery Mode
    http://ipod.about.com/od/iphonetroubleshooting/a/Iphone-Recovery-Mode.htm
    Saw this solution on another post about an iPad in a school enviroment. Might work on your iPad so you won't lose everything.
    ~~~~~~~~~~~~~
    ‘iPad is disabled’ fix without resetting using iTunes
    Today I met my match with an iPad that had a passcode entered too many times, resulting in it displaying the message ‘iPad is disabled – Connect to iTunes’. This was a student iPad and since they use Notability for most of their work there was a chance that her files were not all backed up to the cloud. I really wanted to just re-activate the iPad instead of totally resetting it back to our default image.
    I reached out to my PLN on Twitter and had some help from a few people through retweets and a couple of clarification tweets. I love that so many are willing to help out so quickly. Through this I also learned that I look like Lt. Riker from Star Trek (thanks @FillineMachine).
    Through some trial and error (and a little sheer luck), I was able to reactivate the iPad without loosing any data. Note, this will only work on the computer it last synced with. Here’s how:
    1. Configurator is useless in reactivating a locked iPad. You will only be able to completely reformat the iPad using Configurator. If that’s ok with you, go for it – otherwise don’t waste your time trying to figure it out.
    2. Open iTunes with the iPad disconnected.
    3. Connect the iPad to the computer and wait for it to show up in the devices section in iTunes.
    4. Click on the iPad name when it appears and you will be given the option to restore a backup or setup as a new iPad (since it is locked).
    5. Click ‘Setup as new iPad’ and then click restore.
    6. The iPad will start backing up before it does the full restore and sync. CANCEL THE BACKUP IMMEDIATELY. You do this by clicking the small x in the status window in iTunes.
    7. When the backup cancels, it immediately starts syncing – cancel this as well using the same small x in the iTunes status window.
    8. The first stage in the restore process unlocks the iPad, you are basically just cancelling out the restore process as soon as it reactivates the iPad.
    If done correctly, you will experience no data loss and the result will be a reactivated iPad. I have now tried this with about 5 iPads that were locked identically by students and each time it worked like a charm.
    ~~~~~~~~~~~~~
    Try it and good luck. You have nothing more to lose if it doesn't work for you.
     Cheers, Tom

  • How can I read the trace data into LabVIEW for E5071B

    HI 
    I am setting up the measurement using vector network analyzer (VNA) E5071B controlled by NI 488.2. How can I read the trace data into LabVIEW and display on the graph? If anyone having an idea or know well about this process please give me the suggestion, I will much appreciate it.
    Many Thanks

    You want to start with the driver
     In case you do not know it, you can do the driver search in LabVIEW from Tools>Instrumentation>Find Instrument Drivers. You might also want to bookmark the Instrument Driver Network for information on what a driver is and how to use it.

  • Layout - This Program can not display the webpage

    Hi Experts,
    I am trying to create adobe forms in Webdynpro ABAP, for that I created a Webdynpro component and then view in it and created the required attributes and nodes and the pdfsource as xstring type.
    When I go to Layout tab it showing "This Program can not display the webpage" and in route element container I created an element and gave as of Interactive forms but the system is not creating any interface nor going into adobe live cycle designer.
    Is it the problem with the Live Cycle Designer or what exactly I have to do now.
    Please help me out.
    Thanks,
    Praveen

    Hi.,
    This seems that u didnt maintained host entries.,
    Click Run -> enter drivers -> goto etc folder -> double click on hosts file -> open with note pad.
    there u need to enter the host entries., like .. 192.....<server_address> <tab> <domain> <tab> <host>
    ask ur basis team., they will configure that..,
    hope this helps u.,
    reply if u need some more clarifications.,
    Thanks & Regards
    Kiran

Maybe you are looking for

  • FBL5N Review Open and Cleared Invoices per Customer

    WHen one of our users goes into FBL5N to review open and cleared invoices he adds the WBS and the Profit Center. When the report runs it is blank. I looked at the invoice itself and the WBS and Profit center is on the invoice but I don't know why it

  • How to set List of String as variable value in BPEL

    I am using java embedding to invoke a method which returns a list of strings. I need to set these values in a variable in BPEL to be used later. I am getting following error while setting the value. <May 2, 2012 5:18:20 PM IST> <Error> <oracle.soa.bp

  • How to use n82's wlan, as internet connection for ...

    Hi everyone! I have a pc without wlan connection and a n82. I have a wireless access point in my room. I want to use the internet connection on my pc, with n82's wlan. How can I use my n82's wlan for sharing the internet connection thought usb cable?

  • Question on installing Elements 8

    What is the best way to install element 8 if you already have elements 5 on your computer?  Is there that many problems with installing 8 while 5 is on your computer or should you delete elements 5 before you install elements 8.  Thanks!

  • How to recover Firefox setup (bookmarks, cookies etc) from ghost image

    How can I recover the Firefox setup from a ghost image of my drive. Which directories should I restore to have same setup as in the image.