Why do I always get the default filter of recommended every time I open dw? I am quite capable of decidling if I want a filter or not. How can I turn it off?

Member Avatar
Member Avatar
+1 forum 67

I wrote an application using pthreads which had 5 threads. 4 of the threads filled up 4 buffers and once they had been filled the main thread would be combine these together. This was achieve using barrier so the main thread would wait until the 4 worker threads had reached the barrier. I am looking at re-writing this but using c++ 11 threads and see there isn't a barrier as such available and wanted to know what would be the best/safest way to achieve the same result as the pthread based program. Thanks in advance.

Member Avatar
Member Avatar
+0 forum 10

I'm totally new to c++ programming and I need to solve this problem: in the class 5 pupils got marks for the course informatics on a total of 30 points. these points have to be typed on the keyboard and have to be changed in percent. the average has to be calculated too. I have to use iterations and I can't use anything other than <iostream>. I tried numerous times to make a decent program but the results are really bad so I'll be useless to show them.

Member Avatar
Member Avatar
+0 forum 2

Hi, I got multiple threads in different classes created in this manner: private ThreadStart someName_TS; public Thread someName_Thread; public void someName() { someName_TS = new ThreadStart(someNameThread); someName_Thread = new Thread(someName_TS); someName_Thread.Start();} } private void someNameThread() { while(!Shutdown) { //Do heavy work } } The heavy work is set to a "while" statement that is always set to false unless the user wants to close the application. Now on my main form I got the following FormClosing code: if (e.CloseReason == CloseReason.UserClosing) { e.Cancel = true; guiThread.closeApp(); } Now where I think I need help is that I just made a …

Member Avatar
Member Avatar
+0 forum 3

I've been wondering for the longest time why I don't get email notifications to threads to which I started or subscribed too ?

Member Avatar
Member Avatar
+0 forum 5

Noticed that Moderator badge has been dropped. I don't really care about the others, but the Mod badge was useful if I had to put my Mod hat on. Now I'm a grumpy git just pretending to be a Mod. OK it's there if you're a thread starter, but not otherwise.

Member Avatar
Member Avatar
+1 forum 10

I wanted to upload an excel file with one of my threads, but it is refused. Do I have to zip it first and if so, why?

Member Avatar
Member Avatar
+0 forum 5

Hello! I'm new to programming and I'm trying to do a basic hotel application using threads in java. Here is what i've already done: //room class public class Room { private int idRoom; private int etaj; private boolean empty; public Room() { this.idRoom = 0; this.etaj = 0; this.empty = false; } public Room(int idRoom, int etaj, boolean empty) { this.idRoom = idRoom; this.etaj = etaj; this.empty = empty; } public int getEtaj() { return etaj; } public void setEtaj(int etaj) { this.etaj = etaj; } public boolean isEmpty() { return empty; } public void setEmpty(boolean empty) { this.empty = …

Member Avatar
Member Avatar
+0 forum 5

I was following along to the following tutorial - [Derek Banas Java tutorial 18 - Threads pt2](http://www.youtube.com/watch?v=G2Xd5avyk_0) and as I decided to go over his tutorial series by following along in notepad++ and compiling with the command line, so that I can experiment and test things I'm unsure about, I figured the problem I encountered must be an error in the my typing. However, after skipping to the second stage, which is when I download his commented source code and read over it in eclipse, I noticed his code was identical. I then opened my code in eclipse and got …

Member Avatar
Member Avatar
+0 forum 5

Hi everyone, I am writing some PDE code, and I am just starting to think about parallelizing it. The code is extremely parallelizable by both CUDA (at the lowest level) and regular threading at the higher level. Specifically, I am coding a matrix multiply, and the matrix is banded, so the multiply is just a sum over the bands of some vector operations. In my optimistic mind, I imagine I could run the band multiplications in parallel by putting them in separate threads, and adding the results later. But I also thought that I could do the vector operations in …

Member Avatar
Member Avatar
+0 forum 1

One thread increases an integer named "counter" , and another decreases the same integer. Using synchronized statement on LockObject to control access to counter. If i understand correctly i have to use an Object reference. Can i use synchronized statement on counter somehow? public class Synchronized_Block_Demo { public static int counter=1; public static Object LockObject = new Object(); public static void Show_LockObject(){ System.out.println("LockObject = " + counter); } public static void main(String[] args) throws InterruptedException { Runnable r0=null,r1=null; Thread a,b; r0=new Thread_increases_LockObject(); r1=new Thread_decreases_LockObject(); a=new Thread(r0); b=new Thread(r1); a.start(); b.start(); a.join(); b.join(); System.out.print("Threads finished!"); } } class Thread_increases_LockObject implements Runnable{ …

Member Avatar
Member Avatar
+0 forum 7

Lately I have seen several threads that people have "tagged" as intended. Why is *tagged* in quotes? Because instead of putting *keywords* into the tags box, users are describing the question they're asking in the thread, and thus creating tags that look this way: **Time zone** `how` `to` `find` `frame` `a` `standardize` `date` `time` `common` `for` `various` `zone?` **I cant create code login** `3` `users` `using` `the` `login` `page` **How to cancel an add operation** `cancel` `add` `operation` `and` `display` `last` `record` `from` `recordset` So, here's my suggestion: Make it so that when the user types a new tag, after …

Member Avatar
Member Avatar
+0 forum 4

Hi, I have a working program and I need to answer the following questions: 1:where was polymorphism was used in this application? 2:identify where overriding or overloading was used in this application? I belive overriding is used by the Runnable method to override the run() method. Would that be a good explenation? I am not sure how to clearly communicate how polymorphism is used. Any ideas on how to explain it? Thanks /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package treading; /** * * @author Q */ //Runnable …

Member Avatar
Member Avatar
+0 forum 2

**Please help me out** I am trying to do the following: "Create a program that calculates prime numbers from a certain number X to a number Y. Modify the program so as to run two threads at the same time. The first thread will start counting from X to Y and the second from Y to Z." I have managed to create the program and get the threads running. My only problem is that for input values greater than 90000, the program is no longer reliable e.g. for a range of 100000 - 150000, the program might output only 1 …

Member Avatar
Member Avatar
+0 forum 1

I see this example frequently and thought I'd give it a shot but I've got something unexpected happening with my Queue. I have multiple threads utilizing my producer class but the output doesn't show that it is being written to by each thread. protected Queue<ProductMessage> prodQueue = new ConcurrentLinkedQueue<>(); @Override public void run() { while (true) { prodQueue.add(new ProductMessage(MP3Util.getRandomProduct(), new Date(), MP3Util.regionLookup(MP3Util.getState()))); System.out.println(Thread.currentThread().getName() + "Queue " + prodQueue.size()); try { Thread.sleep(2000); } catch (InterruptedException ex) { Logger.getLogger(ProductProducer.class.getName()).log(Level.SEVERE, null, ex); } } Thread p1 = new Thread(new ProductProducer()); Thread p2 = new Thread(new ProductProducer()); p1.start(); p2.start(); The output shows: Thread-1Queue 3 …

Member Avatar
Member Avatar
+0 forum 12

As C++ has nice read me's like, `C / C++ FAQ's and Practice problems`, `C++ Books`, `"Flushing" the input stream` , how about some read mes's in PHP forum. Its a widely used language like C++, so it would be nice to have some read me's. What do others think about it ?

Member Avatar
Member Avatar
+0 forum 39

i've just started learning the C# language and this is my first program to use threads. I don't understand why the consumer thread doesn't get called( only after the producer has stopped)and when it gets called it doesn't consume anything, also I've noticed that the majority of produced elements are of the same values. Here is the full code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace Sem_example_luci { class Semaphore { private Object oLock; private int iResourceAccesses; private Boolean isBinary; // private LinkedList<Thread> vWaitingTh; private Semaphore() { this.oLock = new Object(); //this.vWaitingTh = new LinkedList<Thread>(); } …

Member Avatar
+0 forum 0

hi, for program to be concurrent i created 4 threads as below Thread th1 = new Thread(a1.run); Thread th2 = new Thread(b1.run); Thread th3 = new Thread(c1.run); Thread th4 = new Thread(d1.run ); th1.Start(); th2.Start(); th3.Start(); th4.Start(); how do i know when the threads are finised done with the work, i print the th4 output to the consol panel and i know it is done with its work) but the program does not end how do i end the threads? appreciate a reply thanks

Member Avatar
Member Avatar
+0 forum 4

HI, How can I read from a txt file using threads in C#, regards

Member Avatar
Member Avatar
+0 forum 2

What should be the output to the following code ? I am confused because I am getting a slightly different output everytime . Any other advise would also be appreciated . #include<iostream> #include<SFML\System.hpp> void apple_thread(void *data) { using namespace std; for(int i = 5 ; i<11 ; i++) { cout<<"I have "<<i<<" apples . "<<endl; } } void main() { sf::Thread thread(&apple_thread); thread.Launch(); using namespace std; for(int i = 5 ; i<11 ; i++) cout<<"I have "<<i<<" oranges . "<<endl; getchar(); }

Member Avatar
Member Avatar
+0 forum 2

public class Thread8 implements Runnable { Demo d; public static void main(String r[]) { new Thread8().disp(); } void disp() { d = new Demo(); new Thread(new Thread8()).start(); new Thread(new Thread8()).start(); } public void run() { d.fun(Thread.currentThread().getId()); } } class Demo { static long f=0; synchronized void fun(long id) { for(int i=1; i<3; i++){ System.out.println(id); Thread.yield(); } } } The program compiles properly but gives a NullPointerException. Why? Why did it not give a compile error for using a non-static reference variable d [Demo d] in static context i.e. in void disp()?

Member Avatar
Member Avatar
+0 forum 2

Here when I execute the program, the output I'm getting on all the tries is 342 (naturally first 34 prints together then 2 seconds later 2 prints). My doubts is that is the order of start() [x.start() followed by y.start()] important in order of execution? Shouldn't the output be 234? P.S. If I alter the start() to y.start() followed by x.start(), then also the output is 342. Help please. Thanks.

Member Avatar
Member Avatar
+0 forum 3

Two doubts: 1. Placing run() inside main() generates "illegal start of expression error"? So why can't run() be placed inside main()? 2.With the above code I am getting the output as A C D B. Why B comes last is because of join(). But what I'm unable to understand is that on invoking start() shouldn't run() get called immediately thus generating the output as C D A B? Help please..Thanks

Member Avatar
Member Avatar
-1 forum 2

I Have This Workers List: private List<Worker> buildWorkerList( Producer producer ) { List<Worker> workerList = new ArrayList<Worker>( 11 ); workerList.add( new WorkerImpl( "Garnett", producer ) ); workerList.add( new WorkerImpl( "Durant", producer ) ); workerList.add( new WorkerImpl( "Xavier", producer ) ); workerList.add( new WorkerImpl( "Daniel", producer ) ); workerList.add( new WorkerImpl( "Leila", producer ) ); workerList.add( new WorkerImpl( "Jimmy", producer ) ); workerList.add( new WorkerImpl( "Monch", producer ) ); workerList.add( new WorkerImpl( "Ronald", producer ) ); workerList.add( new WorkerImpl( "Ascah", producer ) ); workerList.add( new WorkerImpl( "Guru", producer ) ); return workerList; } I need to have my producer allocate 100 …

Member Avatar
+0 forum 0

I am in the process of creating a jackpot game. At the moment I am stuck trying to cycle through the different pictures and stop on a random picture for 5 different slots. So far I have this for animating: private void animatePictures() { Thread timer = new Thread() { public void run() { while(keepGoing){ for (int i = 1; i < 4; i++) { images = new ImageIcon("image" + i + ".png"); firstPictureLabel.setIcon(images); secondPictureLabel.setIcon(images); thirdPictureLabel.setIcon(images); fourthPictureLabel.setIcon(images); fifthPictureLabel.setIcon(images); try { sleep(100); } catch(InterruptedException e) { } } } } }; timer.start(); } How could I stop a picture in a …

Member Avatar
Member Avatar
+0 forum 3

Hi! I'm trying to emplement the job queue. Somehow i can't initialize it: the queue is empty `Inline Code Example Here` //INCLUDES #include <stdio.h> #include <stdlib.h> #include <semaphore.h> #include <pthread.h> //GLOBALS pthread_mutex_t job_queue_mutex = PTHREAD_MUTEX_INITIALIZER; int i; #define N_threads 10 int val=0; //STRUCTURES typedef struct job { int data; struct job *next; }job_t; // A linked list of jobs. job_t *job_queue=NULL; // A semaphore counting the number of jobs in the queue. sem_t job_queue_count; //FUNCTION'S DECLARATION int init_job_queue(job_t **head,job_t **tail);//initialize the queue int add_node_to_head(job_t *head);//add job to queue void remove_node_from_tail(job_t **head);//remove job from queue in FIFO order int process_job(job_t *the_job);//thread …

Member Avatar
Member Avatar
+0 forum 1

I'm trying to seem if(t3.alive) is not ever entered. It successfully goes through t1 and t2 if statment but skips over three. I've tried the do while, while (like seen). I would think if t3 is still alive the loop would still go then once it's not, its out but i'm not seeing that result. even if it wasn't started it would at least go in immediately but it's just skiped over help please while ((t3.IsAlive) || ((t2.IsAlive) || (t1.IsAlive))) { if (!t3.IsAlive && itc == false) { it.Stop(); itc = true; } if (!t1.IsAlive && mtc == false) { …

Member Avatar
Member Avatar
+0 forum 12

Okay, first off, this is not a thread for an answer like "Use delegates", or the like. I know how to use them, but one time I forgot to use them, and when going over my code, it worked, and I've been wondering why for a while. http://screensnapr.com/e/xx68FK.jp[/img] The image shows what I am saying. All the ones that have boxes around them, do not work. However, the ones that [b]do not[/b] have boxes around them, do work. I can honestly not come to a conclusion as to why this is at all. I am stumped.

Member Avatar
Member Avatar
+0 forum 2

Hi, I'm trying to create a thread for running some tasks. I copied the code from an old console application (which compiles fine), but can't figure out why it's not working now. I have searched for the error code and came across this suggestion: "Are you passing the name of a member function as a parameter accidentally?" :-O Lift.h: [code="C++"] void operateIt(void *); [/code] Lift.cpp: [code="C++"] void Lift::operate(int aCurrentFloor) { //start thread that looks at the queue and moves between floors _beginthread(operateIt, 5, &aCurrentFloor); } void Lift::operateIt(void * arg) { int s = *( (int*) arg ); while(1){ //do magic …

Member Avatar
Member Avatar
+0 forum 1

[CODE=java]import java.util.Scanner; class Sum { private int value; public int get() { return value; } public void set(int sum) { this.value = sum; } } class Summation extends Thread { private int upper; private int lower; private Sum sumValue; public Summation(int upper, Sum sumValue) { if (upper < 0) throw new IllegalArgumentException(); this.upper = upper; this.sumValue = sumValue; } public void run() { int sum = 0; for (int i = 1; i >= lower && i <= upper; i++) sum += i; System.out.println(this.getName() + " is done"); sumValue.set(sum); System.out.println(this.getName() + " " + sum); } } public class MultithreadSum …

Member Avatar
+0 forum 0

The End.