Using threads in a process of two or more tasks concurrently?

Dear,
I need to develop through a Java application in a process that allows the same process using Threads on two or more tasks can be executed concurrently. The goal is to optimize the runtime of a program.
Then, through a program, display the behavior of a producer and two consumers at runtime!
Below is the code and problem description.
Could anyone help me on this issue?
Sincerely,
Sérgio Pitta
The producer-consumer problem
Known as the problem of limited buffer. The two processes share a common buffer of fixed size. One, the producer puts information into the buffer and the other the consumer to pull off.
The problem arises when the producer wants to put a new item in the buffer, but it is already full. The solution is to put the producer to sleep and wake it up only when the consumer to remove one or more items. Likewise, if the consumer wants to remove an item from the buffer and realize that it is empty, he will sleep until the producer put something in the buffer and awake.
To keep track of the number of items in the buffer, we need a variable, "count". If the maximum number of items that may contain the buffer is N, the producer code first checks whether the value of the variable "count" is N. If the producer sleep, otherwise, the producer adds an item and increment the variable "count".
The consumer code is similar: first checks if the value of the variable "count" is 0. If so, go to sleep if not zero, removes an item and decreases the counter by one. Each case also tests whether the other should be agreed and, if so, awakens. The code for both producer and consumer, is shown in the code below:
#define N 100                     / * number of posts in the buffer * /
int count = 0,                     / * number of items in buffer * /
void producer(void)
int item;
while (TRUE) {                    / * number of items in buffer * /
produce_item item = ()           / * generates the next item * /
if (count == N) sleep ()           / * if the buffer is full, go to sleep * /
insert_item (item)                / * put an item in the buffer * /
count = count + 1                / * increment the count of items in buffer * /
if (count == 1) wakeup (consumer);      / * buffer empty? * /
void consumer(void)
int item;
while (TRUE) {                    / * repeat forever * /
if (count == 0) sleep ()           / * if the buffer is full, go to sleep * /
remove_item item = ()           / * generates the next item * /
count = count - 1                / * decrement a counter of items in buffer * /
if (count == N - 1) wakeup (producer)      / * buffer empty? * /
consume_item (item)      / * print the item * /
To express system calls such as sleep and wakeup in C, they are shown how to call library routines. They are not part of standard C library, but presumably would be available on any system that actually have those system calls. Procedures "insert_item and remove_item" which are not shown, they register themselves on the insertion and removal of the item buffer.
Now back to the race condition. It can occur because the variable "count" unfettered access. Could the following scenario occurs: the buffer is empty and the consumer just read the variable "count" to check if its value is 0. In that instant, the scheduler decides to stop running temporarily and the consumer starting to run the producer. The producer inserts an item in the buffer, increment the variable "count" and realizes that its value is now 1. Inferring the value of "count" was 0 and that the consumer should go to bed, the producer calls "wakeup" to wake up the consumer.
Unfortunately, the consumer is not logically asleep, so the signal is lost to agree. The next time the consumer to run, test the value of "count" previously read by him, shall verify that the value is 0, and sleep. Sooner or later the producer fills the whole buffer and also sleep. Both sleep forever.
The essence of the problem is that you lose sending a signal to wake up a process that (still) not sleeping. If he were not lost, everything would work. A quick solution is to modify the rules, adding context to a "bit of waiting for the signal to wake up (wakeup waiting bit)." When a signal is sent to wake up a process that is still awake, this bit is turned on. Then, when the process trying to sleep, if the bit waiting for the signal to wake up is on, it will shut down, but the process will remain awake. The bit waiting for the signal to wake up is actually a piggy bank that holds signs of waking.
Even the bit waiting for the signal to wake the nation have saved in this simple example, it is easy to think of cases with three or more cases in which a bit of waiting for the signal to wake up is insufficient. We could do another improvisation and add a second bit of waiting for the signal to wake up or maybe eight or 32 of them, but in principle, the problem still exists.

user12284350 wrote:
Hi!
Thanks for the feedback!
I need a program to provide through an interface with the user behavior of a producer and two consumers at runtime, using Threads!So hire somebody to write one.
Or, if what you really mean is that you need to write such a program, as part of your course work, then write one.
You can't just dump your requirements here and expect someone to do your work for you though. If this is your assignment, then you need to do it. If you get stuck, ask a specific question about the part that's giving you trouble. "How do I write a producer/consumer program?" is not a valid question.

Similar Messages

  • How can I use TopLink for querys that have two and more tables?

    I use TopLink today, and I can use one table to query, but how can I use TopLink for querys that have two and more tables?
    Thank you for see and answer this question.

    You can write a custom SQL query and map it to an object as needed. You can also use the Toplink query language "anyOf" or "get" commands to map two tables as long as you map them as one to one (get command) or one to many (anyOf command) in the toplink mapping workbench.
    Zev.
    check out oracle.toplink.expressions.Expression in the 10.1.3 API

  • How to start two or more tasks at the same time?

    Hi all,
      I have few tasks setup to send analog and digital output to different channel with buffer and given sampling rate. I need to precisely control the timing of samples output to each channel. But if I start the task in labwindows
        DAQmxStartTask(taskHandle1)
        DAQmxStartTask(taskHandle2)
        DAQmxStartTask(taskHandle3)
    they actually not start at the same time since they are exectued in sequence. I wonder how much time delay will be if I start each task in sequence. Also, is it possible to have 2 or more tasks started at the same time?
    p.s. I think it will be easier if I could bind different channels to a single virtual channel but I don't think it is possible to create a signle virtual channel with analog channel and digitial channel.

    RobertoBozzolo wrote:
    I had success in doing something similar on the input side by sharing the same sample clock across the tasks with:
    DAQmxCfgSampClkTiming (DigitalTaskHandle, "/Dev1/ai/SampleClock", 1000, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 1000);
    In my application I had the power to have the same acquisition speed on all tasks, so that the sample clock could be same on all of them.
    The conceptual framework is this one (pay attention to the step order):
    Setup your AO task
    Setup your DO task
    Set the DO task to share the AO sample clock with the instruction given above
    Start the DO task (IMPORTANT: it must precede the AO task start, so that DO task is started but does not generate samples)
    Start the AO task
    If you have different sample speed on the tasks, I suppose an alternative is to use a start trigger sharing some digital signal among them. I have seen examples that use a separate counter output as a start trigger.
    Thanks a lot. It gives me a good information, I think that will help. I am encountering another sitution, if task1 is analog output with continuous samples with rate 100000 samples/second and task2 and task3 are a single digital sample (i.e. write only 1 sample to one digital line). In task1, I write continuous samples and there will be a spike (of 2.2V) at the time 1.2ms after the task started. And I want to write to the digital channels (task2 and task3) at 0.2ms before the spike was set in task1. In this case, there is only one sample written to DO task, so how does it work to use the sample clock source?
    In your last suggestion, we could use tirgger but how does it help? Is there any example I can follow? Thanks.

  • How do I use the same Apple ID on two or more devices?

    I try to set up an Apple ID on my iPad but I already have one set up for my iPhone which is associated with my email. It makes me use a different email address which I don't want to do

    You certainly can use the same ID for multiple devices. In fact, if you do then you can share the apps and content between devices. I have an iPad and iPod and use the same Apple ID for them both.
    If I were using different ID's for each  device then I'd need to buy two copies of some apps, which would just be no fun at all.

  • How to use one stream by two or more threads?

    Hey guys,
    i have got a little problem and do not know how to solve it. i hope you guys can are able to help me.
    i have opened a bluetooth socket connection. now i want to use these streams by three or more threads. one thread should only read from an input stream. the other threads are supposed to write on the ouput stream.
    (I think) I am only able to open one stream in each direction.
    How do I realize the use of the output stream by two indepent threads?
    thanks for your help!

    thank you for the hint!
    i will search it or do you know a good tutorial?

  • Cfcache template cf10 issue. When I use it thousands ( 15000) of threads remains in process coldfusion.exe until server crash.

    Hi,
    Using cfcache to cache templates for a short period of time, the number of threads in coldfusion.exe process increase unexpectedly. Moreover, these threads remains in process (view resource monitor). We don't know why. Maybe an xml config file of CF10 take control of these threads?
    When I use this code:
    <cflock name="prodDetail#URL.ID#" type="exclusive" timeout="10000">
    <cfcache timespan="#createTimeSpan(0,0,0,30)#" key="prodDetail#code#" id="prodDetail#code#" name="prodDetail#code#">
    </cfcache>
    </cflock>
    Thanks in advance.

    Hi,
    This is Windows audit feature, I suppose that you have known that, actually, when you configure this audit policy, audit event is generated when sensitive privilege requests are made. This includes following objects:
    • A privileged service is called.
    • One of the following privileges are called:
    ◦Act as part of the operating system
    ◦Back up files and directories
    ◦Create a token object
    ◦Debug programs
    ◦Enable computer and user accounts to be trusted for delegation
    ◦Generate security audits
    ◦Impersonate a client after authentication
    ◦Load and unload device drivers
    ◦Manage auditing and security log
    ◦Modify firmware environment values
    ◦Replace a process-level token
    ◦Restore files and directories
    ◦Take ownership of files or other objects
    So the culprit is not Windows system, this should be caused by a massive privileged operations. As we can see, the privileged operation is
     SeTakeOwnershipPrivilege. In my environment, if I run some opearations such as backup, there are
     records as expected, you suspected this is related to Acronis services, if these services require so many privileged operations, Windows would audit this via its mechanism.
    If you have any feedback on our support, please click
    here
    Alex Zhao
    TechNet Community Support

  • Playing two midi files at once using threads?

    Hi all, I have the following simple code here which plays a midi file, but I'm not sure how to use threads to play two midi files at once:
    import org.jfugue.*;
    import javax.sound.midi.*;
    import java.io.*;
    public class MidiPlayer {
    public static void main (String [] args) {
    try {
    Player player = new Player();
    player.playMidiDirectly(new File("C:\\Sounds\\bach.mid"));
    } catch (IOException e) {
    } catch (InvalidMidiDataException e) {
    Is there a way to use a thread for this class so that in another class I can call 'start' twice and have the parameters be the midi file locations (e.g. "C:\\Sounds\\bach.mid" & "C:\\Sounds\\bach2.mid").
    Any kind of help would be great, thank you!

    Something like the below.
    import org.jfugue.*;
    import javax.sound.midi.*;
    import java.io.*;
    public class MidiPlayer {
    public static void main (String [] args) {
    String fileName = "c:\\Sounds\\bach.mid";
    Thread t1 = new Thread(new MyRunable(fileName));
    t1.start();
    String fileName2 = "c:\\Sounds\\bach2.mid";
    Thread t2 = new Thread(new MyRunable(fileName2));
    t2.start();
    } // main
    class MyRunnable implements Runnable {
    private String fileName
    public MyRunnable( String fileName) {
      this.fileName = fileName;
       public void run() {
         Player player = new Player();
        player.playMidiDirectly(new File(fileName));
    } // MyRunnable
    } //

  • Error while using threads in proc program

    Hi,
    I am getting the error fetched column value NULL (-1405) in proc program while using the threads.
    The execution of the program is as follows.
    Tot_Threads = 5 (Total threads, totally 5 records with value instance names)
    No_Of_threads = 1 (No Of threads executed at the same time)
    Example :
    INSTANCE_NAME – Link1, link2, link3, link4, link5 (All different Databases)
    NO_OF_THREADS - 5
    Threading Logic:
    Based on the maintanence NO_OF_THREADS, the program will process.
         If (NO_OF_THREADS == 0)
              Process_Sequence
         else
              if NO_OF_THREADS == TOT_THREADS
                   Process_Type1
              else
                   Process_Type2
    In a loop for all different instances,
    New context area will be created and allocated.
         New oracle session will be created.
         New structure will be created and all global parameters are assigned to that structure.
         For each instance, a new thread will be created (thr_create) and all the threads will call
         the same(MainProcess) function which takes the structure as parameter.
         At the end of every session, the corresponding oracle session will logged out.
    Process_Type1 logic :
         /* For Loop for all threads in a loop */
         for(Cnt=0;Cnt < Tot_Threads;Cnt++)
              /* Allocating new contect for every different thread */
              EXEC SQL CONTEXT ALLOCATE :ctx[Cnt];
              /* Connected to new oracle session */
              logon(ctx[Cnt],ConnStr);          
    /* Assigning all the global parameters to the structure and then passing it to InsertBatching function */
              DataSet[Cnt].THINDEX=Cnt;
              DataSet[Cnt].sDebug=DebugMode;
              strcpy(DataSet[Cnt].THNAME,(char *)InsNameArr[Cnt].arr);
              DataSet[Cnt].ctx=ctx[Cnt];
              /* creating new threads for time in a loop */
    RetVal = thr_create(NULL,0,InsertBatching,&DataSet[Cnt],THR_BOUND,&threads[Cnt]);
              sprintf(LocalStr1,"\nCreated thread %d", Cnt);
              DebugMessage(mptr,LocalStr1,DebugMode);
         for(Cnt=0;Cnt <Tot_Threads;Cnt++)
              /* Waiting for threads to complete */
              if (thr_join(threads[Cnt],NULL,NULL))
                   printf("\nError in thread Finish \n");
                   exit(-1);
              /* Logout from the specific oracle session */     
              logoff(ctx[Cnt]);
              /* Free the context area after usage */
              EXEC SQL CONTEXT FREE :ctx[Cnt];     
    used functions:
              thr_create with thr_suspend option
              thr_join to wait for the thread to complete
    Process_Type2 logic :
         Here the idea is , if the load is heavy , then we can change the maintanence of NO_OF_THREADS (Ex - 2), so that only two threads will be executed in the same time , others should wait for      the same to complete ,once the first two threads completed and the next two should be started and then in the same manner it will do for all the threads.
    The parameters passing and the structure passing are same as above.
    Here all threads will be created in suspended mode, and then only No_Of_threads(2) will
    be started, others will be in suspended mode, once the first two is completed then the
    other two thread will be started and in the same manner other threads.
         used functions:
              thr_create with thr_suspend option
              thr_continue to start the suspended thread
              thr_join to wait for the thread to complete
    Process_Sequence logic :
    Here the idea is , to run the program for all the instances , without creating the threads.Hence in the for loop , one by one instance will be taken and call the same function to Process. This will call the same function repeated for each different value. The parameters passing and the structure passing are same as above.
         The InsertBatching function will prepare the cursor and pick all records for batching and then , it will call other individual functions for processing. For all the functions the structure variable will be passed as parameter which holds all the neccessary values.
    Here in all the sub functions , we have used
         EXEC SQL CONTEXT USE :Var;
         Var is corresponding context allocated for that thread, which we assume that the corresponding context is used in all sub functions.
         EXEC SQL INCLUDE SQLCA;
    This statement we have given in InsertBatching Function not in all sub functiosn
    Example for the Sub functions used in the program :-
    /* File pointer fptr and dptr are general file pointers , to write the debub messages, DataStruct will hold all global parameters and also context area .
    int Insert(FILE fptr,FILE dptr,DataStruct d1)
    EXEC SQL BEGIN DECLARE SECTION;
         VARCHAR InsertStmt[5000];
    EXEC SQL END DECLARE SECTION;
    char LocalStr[2000];
    EXEC SQL CONTEXT USE :d1.ctx;
    InsertStmt will hold insert statement      
    EXEC SQL EXECUTE IMMEDIATE :InsertStmt;
    if (ERROR)
         sprintf(LocalStr,"\nError in Inserting Table - %s",d1.THNAME);
         DebugMessage(dptr,LocalStr,d1.sDebug);
         sprintf(LocalStr,"\n %d - %s - %s",sqlca.sqlcode,ERROR_MESG,d1.THNAME);
         DebugMessage(dptr,LocalStr,d1.sDebug);
         return 1;
    return 0;
    I get this error occationally and not always. While preparing the sql statement also i am getting this error.
    The code contains calls to some stored procedures also.
    Thanks in advance

    in every select nvl is handled and this error is occuring while preparing statements also

  • How to use Thread

    Hi,
    I am trying to write a program that does a background process. The process is controlled by two buttons: Start and Stop. I thought I'd use threads, but it does not work; the start button remains depressed and the user cannot click on the Stop button. The line calling run() is executed and execution transfers to the run method in my Thread subclass, which is wrapped in an infinite loop. The line after the run() method is never reached. It is as if it is not creating an extra thread at all.
    I have written something basic which is similar, the same problem occurs with this code:
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class CounterFrame extends JFrame {
        private JPanel pnButtons;
        private JButton btStart;
        private JButton btStop; 
        private ThreadTester threadtester;
        public CounterFrame() {
            pnButtons = new JPanel();
            btStart = new JButton("Start");
            btStop = new JButton("Stop");
            btStart.addActionListener(new StartListener());
            btStop.addActionListener(new StopListener());   
            pnButtons.add(btStart);
            pnButtons.add(btStop);
            add(pnButtons);
            pack();
            threadtester = new ThreadTester();
        private class StartListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                threadtester.run();
        private class StopListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                try {
                    threadtester.sleep(Long.MAX_VALUE);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
        private class ThreadTester extends Thread {
            int counter;
            public ThreadTester() {
                counter = 0;
            public void run() {
                while(true) {
                    System.out.println(counter);
                    counter++;
                    try {
                        sleep(1000);
                    } catch (InterruptedException ex) {
                        ex.printStackTrace();
                    yield();
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new CounterFrame().setVisible(true);
    }Can anyone advise where I am going wrong, please?

    Please run, don't walk to the article on the Sun site (you can search for it) entitled Concurrency and Swing (or something similar). Problems I see include:
    1) Don't call run on a thread as that will just "run" the run method and not create a background thread. Instead you call "start".
    2) Don't call Thread.sleep() on the EDT or the Event Dispatch Thread. This is the single thread that Swing uses to draw components and to interact with the user. Calling Thread.sleep on it will put your whole program to sleep which is not what you want.
    3) Consider using a Swing Worker, or better still a Swing Timer.
    Again, read the article and you will understand this better.

  • Using threads in a neural network

    Hello,
    I've written a neural network and I'm wondering how I could use threads in it's execution to 1) increase (more precisely achieve!) learning speed and 2) print out the current error value for the network so that I can see how it is working without using the de-bugger. Basically, i've read the Concurrency tutorial but I'm having trouble getting my head around how I can apply it to my network (must be one of those days!)
    I'll give a brief explanation of how i've implemented the NN to see if anybody can shed any light on how I should proceed (i.e. whether it can be threaded, what parts to thread etc.)
    The network consists of classes:
    Neuron - stores input values to be put into the network and performs the activation functions (just a mathematical operation)
    WeightMatrix - contains random weights in a 2-D array with methods for accessing and changing those weights based on output error
    Layer - simply an array that stores a collection of neurons
    InputPattern - stores the values in an array and target value of a pattern (e.g. for logical AND i would store in pattern[0] = 1; pattern [1] = 1; target = 1;)
    PatternSet - set of InputPatterns stored so that they can be input into the network for learning
    NeuralNetwork - the main class that I want to thread. This class contains multiple layers and multiple WeightMatrices (that connects the neurons in each layer). The learn algorithm then uses the methods of the previous classes to generate neuron inputs and ouputs and error values given a specific input. It uses a loop that iterates through as follows:
        public float learn(PatternSet p)
            InputPattern currentPattern = null;
            double netError=0f;
            float previousError=0f;
            float outputValue = 0f;
            float sum=0f;
            float wcv=0f;
            float output1=0f;
            float output2=0f;
            float currentError=0f;
            float multiply=0f;
            float outputError = 0f;
            float weight = 0f;
            int count;
            int setPosition=0;
            int setSize = p.getSetSize();
            Neuron outputNeuron = layers[getNumberOfLayers()-1].getNeuron(0);
            //execute learning loop and repeat until an acceptable error value is obtained
            do
                 //set input layer neuron values to pattern values
                currentPattern = p.getPattern(setPosition);
                for (int i=0; i<currentPattern.getPatternSize(); i++)
                    layers[0].getNeuron(i).setNeuronInput(currentPattern.getValue(i));
                currentError = layers[getNumberOfLayers()-1].getNeuron(0).getOutputError();
                for (int a=0; a<layers[getNumberOfLayers()-1].getNumberOfNeurons(); a++)
                    //set target value of output neuron
                    layers[getNumberOfLayers()-1].getNeuron(a).setTarget(currentPattern.getTarget());
                //iterates between weight layers - i.e. there will be a weight matrix between each layer of the NN
                for (int i=0; i<getNumberOfLayers()-1; i++)
                    for (int j=0; j<layers[i+1].getNumberOfNeurons(); j++)
                        sum =0f;
                        count=0;
                        for (int k=0; k<layers.getNumberOfNeurons(); k++)
    weight = weights[i].getWeight(k,j);
    outputValue = layers[i].getNeuron(count).getOutput();
    multiply = layers[i].getNeuron(count).getOutput() * (weights[i].getWeight(k,j));
    //add values
    sum = sum + multiply;
    count++;
    //check that all weighted neuron outputs have been completed
    if (count == layers[i].getNumberOfNeurons())
    //pass results to neuron
    layers[i+1].getNeuron(j).setNeuronInput(sum);
    //activate neuron
    layers[i+1].getNeuron(j).neuronActivation();
    //calculate output error of neuron for given input
    layers[i+1].getNeuron(j).calculateOutputError();
    //check that output layer has been reached and all neurons have been summed together
    if (i == getNumberOfLayers()-2 && count == layers[i].getNumberOfNeurons())
    outputError = layers[i+1].getNeuron(j).getOutputError();
    netError = layers[i+1].getNeuron(j).getNetError();
    for (int a=getNumberOfLayers()-1; a>0; a--)
    for (int b=0; b<layers[a-1].getNumberOfNeurons(); b++)
    for (int c=0; c<layers[a].getNumberOfNeurons(); c++)
    output1 = layers[a-1].getNeuron(b).getOutput();
    output2 = layers[a].getNeuron(c).getOutput();
    wcv = learningRate * (outputError) * output1 * output2 * (1-output2);
    weights[a-1].changeWeight(wcv, b, c);
    learningCycle++;
    if (setPosition < setSize-1)
    setPosition++;
    else
    setPosition=0;
    while (netError > acceptableError && learningCycle < 1000000000);
    return currentError;
    }At the moment the net doesn't seem to learn to an acceptable degree of accuracy, so I was looking to use threads to monitor it's error value change while I left it running just to ensure that it is working as intended (which it seems to be based on NetBeans debugger output). For the moment, all I'm aiming for is an output of the netError value of the NN at a particular time - would this be possible given my current implementation?
    Thanks for the help,
    Nick                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    For huge NN and a really multi-core CPU (reporting to OS as a multiple CPU's) one may benefit from having:
    - an example pump
    - a separate threads for calculation of forward and backwards propagation with in/out queues.
    Example pump pumps one forward example to each forward processing thread. It waits for them to complete. Then it reads their output and finds errors to backpropagate. It pumps errors to back-propagation threads. They finds weights correction but does not update weight matrix only are pushing them to the output temporary arrays. The example pump takes those corrections, combines them an updates weights.
    Redo from start.
    The rule of thumb for high-performance is - avoid locks. If must access data which are changing, make a copy of them in bulk operation, prepare bulk result and read-write in bulk operations.
    In this example a whole bunch of weight matrixes and states of neurons are such a kind of data. Each thread should use separate copy and the teaching pump should combine them together. This makes one to split data in two blocks - non-changing, common for all threads (the geometry of NN and weights) and changing, separate for each thread (weight correction, in/out of neurons).
    Avoid "new", "clone" and etc. for the preference of System.arraycopy on existing data.
    Regards,
    Tomasz Sztejka.

  • How can I use the same "I Tunes" on two different computers

    I’m using two different kinds of Personal Computer: One is Desktop PC And the other one is Notebook .
    In each computer there are the same songs and when I get the new ones to the Desktop I want them to be placed on the Notebook or reverse.
    Where does the I Tunes save the playlist on the hard drive ?
    I have prepared a playlist on my Notebook and want it to be seen on the Desktop but I dont want to fallow the steps File > Library > Export Playlist on the Notebook. Is there any other way to make this issue instead of the mentioned steps.
    How can I see the same Playlists and songs on two different computers ( notebook and desktop) including the updating processes.
    Operating systems of the computers:
    Desktop: XP Pro
    Notebook: Vista Bussiness

    I use SyncToy 2.0 to keep two instances of my library in sync. SyncToy's preview will show which files it is about to update giving you a chance to spot unexpected changes and during the run only the changed files will be copied saving lots of time.
    As long as I sync after making updates at one instance of the library before making any updates at the other then everything works just fine. I periodically run iTunes Folder Watch to check for any orphaned entries or new items that haven't been imported into the active library. If your machines are regularly networked together this process is fairly straightfoward. Mine are in disparate locations so I use one of the (physically) small WD My Passport host powered drives which I take between home & work, synchronising at either end. This gives me three complete copies of my library so I'm covering backup & synchronisation in the same operation.
    When connecting my iPod at either location iTunes recognises itself as the "home" library for the iPod so I'm able to use the sync with selected playlists option without getting warning messages about the iPod being synced with a different library.
    tt2

  • Processing a Two-Step Group in parts

    Dear all,
    I am processing my Two step group with LT0e and would like to process it partially.
    Is there a way to do that?
    Some background: When Picking from one of the Storage Types I want to use a Return Storage Type. Since this applies to one Outbound flow only, I have defined the Return Storage Type in my WM movement, NOT in the Pick Storage Type.
    In 2-step customizing, I have omitted the movement type, and am entering the Movement Type myself in LT0e. Only thing, I want to be able to make some kind of selection here so with my Movement Type I process only those items from the One Storage Type I am focussing on.
    To much info?
    Again, thank you for your time.
    Sandeep

    In LT0E once you have selected your group and via subsequent function do the picking step(2step picking -> start picking), you should be able to make the lines which you dont require "Inactive". Then you have only those lines for which you want to do the picking with your required movement type.
    Sandeepan

  • Using threads to change button status

    Hi all
    im reworking my conway life adt and trying to build it into an ap (as i have it working as an applet)
    as applets have a repaint command then implementing the generations was pretty easy.
    However in an application i will have to use threads wont i?
    so what i have done is built an ap that builds the life grid using swing buttons (this isnt a swing question by the way its a thread question :p)
    so how would i go about threading my application so it doesnt freeze up?
    here is the code from my swing ap
    import javax.swing.*;
    import java.awt.*;
    public class LifeAp
    private Life gLife;
    private JButton[][] buttons;
    private JFrame frame;
         public LifeAp(int y, int x)
         gLife=new Life(y,x);
         buttons=new JButton[y][x];
         for (int yc=0;yc<y;yc++)
              for (int xc=0;xc<x;xc++)
                   JButton btn=new JButton();
                   btn.setBackground(new Color(204, 204, 204));
                   btn.setText("");
                   buttons[yc][xc]=btn;
         initLife();
         public void buildForm()
         frame = new JFrame("Life");
         frame.getContentPane().setLayout
               (new GridLayout(buttons[0].length,buttons.length));
         for (int y=0;y<buttons.length;y++)
              for (int x=0;x<buttons[0].length;x++)
                   frame.getContentPane().add(buttons[y][x]);
         frame.pack();
         public void setButtons()
         for (int y=0;y<buttons.length;y++)
              for (int x=0;x<buttons[0].length;x++)
                   if (gLife.getStatus(y,x)==0)
                        buttons[y][x].setBackground(new Color(204, 204, 204));
                   else
                        buttons[y][x].setBackground(new Color(255, 255, 0));
         public void initLife()
         buildForm();
         gLife.generateMap();
         setButtons();
         public void show()
         frame.setVisible(true);
         private void exitForm(java.awt.event.WindowEvent evt)
         System.exit(0);
         public static void main(String[] args)
         new LifeAp(16,16).show();
    }the form builds just fine.
    now in the Life adt i have a method called generation()
    so when i call gLife.generation(); the next life phase is calculated
    so i need in a thread to basically say
    gLife.generation();
    setButtons();which will update life then colour the buttons accordingly.
    however i think that maybe im going to hit problems because of static and non static methods etc.
    have i approached this the wrong way? or is this something quite easy to implement into a thread?

    ok so now i have
         public void start()
         animator = new Thread(this);
         animator.start();
         public void run()
         long tm = System.currentTimeMillis();
         while (Thread.currentThread() == animator)
              gLife.generation();
              setButtons();
              validate();
              show();
              try
                   tm += delay;
                   Thread.sleep(Math.max(0, tm - System.currentTimeMillis()));
              catch (InterruptedException e)
                   break;
              frame++;
         }and my current main is
         public static void main(String[] args)
         LifeAp l=new LifeAp(64,64);
         l.show();
         l.start();
         }what should i have in my main code to start my thread?
    if i have
    public static void main(String[] args)
         LifeAp l=new LifeAp(64,64);
         l.show();
         }then the process doesnt run, it just displays the first generation then stops.
    so what do i need to include?

  • How to use loop in BPEL Process

    Hi friends
    I have done a bpel process which picks up XMl file using File Adapter and imports the data from the XMl file to oracle db table using DB adapter....
    But here the XMl file which have only one row ..if i want insert the XML file which have two or more rows i want to use loop in my BPEL process how to use the loop in my bpel process ?
    In my BPEL process i have used receive ,transform , and invoke activity where can i use loop in my BPEL process
    Advance Thanks
    AT

    Hi Friend thanks
    Hi Oracler how to make use of transform activity and use a for each in it.?
    iam not getting i try can u please explain some more in brief
    Thanks
    AT

  • Work manager using thread.sleep or delay doesn't work

    Hi all,
    I used Spring framework and oracle weblogic 10.3 as a container.
    I used workmanager for manage my thread, I already made one thread that managed by workmanager. Fortunately spring provide the delegation class for using workmanager, so I just need to put it on applicationContext.xml.
    But when I put the "while" and TimeUnit for sleep the process on desired delayed time, the deployment process never finished. It seems the deployment process never jump out from while loop for finishing the deployment.
    Why?, As I know using typical thread, there is no issue like this. Should I use another strategy for make it always loop and delay.
    This is my simple code :
    import java.util.concurrent.TimeUnit;
    import org.springframework.core.task.TaskExecutor;
    public class TaskExecutorSample{
         Boolean shutdown = Boolean.FALSE;
         int delay = 8000;
         TimeUnit unit = TimeUnit.SECONDS;
         private class MessageGenerator implements Runnable {
              private String message;
              public MessageGenerator(String message){
                   this.message = message;
              @Override
              public void run() {
                   System.out.println(message);
         private TaskExecutor taskExecutor;
         public TaskExecutorSample(TaskExecutor taskExecutor){
              this.taskExecutor = taskExecutor;
              try {
                   while (shutdown.equals(Boolean.FALSE)){
                        this.printMessage();
                        unit.sleep(delay);
              } catch (Exception e) {
                   System.out.println(e.getMessage());
         public void printMessage() {
              taskExecutor.execute(new MessageGenerator("Print this Messages"));
    Really thanks in advance.
    Regards,
    Kahlil
    Edited by: Kahlil on May 26, 2010 2:38 PM
    Edited by: Kahlil on May 26, 2010 2:42 PM

    Hi,
    i m not sure whether it's an issue with Spring or not. But i tried using Thread.sleep(1000) in a Simple webapplication to see Workmanagers works properly or not. I found that it works extremely great: http://weblogic-wonders.com/weblogic/2010/01/24/workmanager-at-webapplication-level/
    Thanks
    Jay SenSharma

Maybe you are looking for

  • Intel Mac mini vs PowerMac Dual G5 storage server

    I would like to setup a server to store family pictures, iTunes purchases and other media. Also I would like to use it as a backup for important documents and data. I have a Intel Mac Mini 1.66 and a G5 PowerMac dual 1.8GHz. I have purchased 4 400GB

  • Can I run adobe flash on ALL window 8 devices?

    Hi all, Does anyone know if I can run flash on ALL windows 8 devices including the new nokia lumia W8 phablet devices and also ALL other W8 tablets made by different manufacturers? ie the devices listed here: http://windows.microsoft.com/en-gb/window

  • Airport Express won't connect to my existing network!!

    I purchase an Airport Express and I want to have it connect to my wireless network, but whenever it "restarts", I just get a message telling me that it can't find the Airport after restarting it. I typed in my router password(40 bit WEP), and it just

  • How do you transfer last backup from external hard drive to a new internal hard drive?

    Hoe do you transfer last backup on an external hard drive onto a newly installed internal hard drice?

  • Bob Sturtevant

    I have a new laptop with 8.1, non touch screen. I installed office 2010 from a disk. I cannot enlarge columns or rows. I see the arrows to enlarge with the pointer but can't move them with the pad. Is there a key to do this with or is there a problem