w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » MULTITHREADING » Page 1
c++ memory leak using threads
Take a look at this modified code: class Foo { public: Foo(const std::size_t& numThreads) :size_(numThreads) {} inline void alloc() { printf("alloc "); std::call_once(alloc_flag, &Foo::alloc_, this); } inline void foo_free() { printf("free "); std::call_once(free_flag, &Foo::free_, this); // Changed from bufferflag } private:

Categories : Multithreading

Use cases for detached threads
Why do you care whether the thread has finished execution? What you care about is whether any work that you need done has been done. If you use some other way to track what work is done, you don't need to wait for the thread to finish execution.

Categories : Multithreading

Multi-thread program(process) on multicore-core processor(s) with hyperthreading
if there is only 1 core of the CPU, the process will get no benefit of parallelism by multi-threading, since the total execution time of the process will not change. Is it true? Only if you are 100% CPU-bound. If you have I/O waits, multiple threads can help a lot even on a single core. if there are more than one cores available, the OS will schedule the threads of the process evenly and

Categories : Multithreading

How to receive thread callbacks in Python
Complement Tkinter with a messaging-layer with an event-routing added While a Tkinter/.mainloop() is a self-contained Model-Visual-Controller system, you may extend it's functionality in a thread-safe, non-blocking mode with an added complementary ( inter-process / any-to-any ) Messaging Layer of your own and equip it's localhost/self actors with a Tkinter-based event-routing mechanism to integra

Categories : Multithreading

Run multiple copies of Speedy or PersistentPerl to be called from Tomcat
Those approaches should reduce the overhead from the start up time of your script. If the script is something that can be run as a CGI program then you might be better offer making it work with Plack and running it with a PSGI server. Your Tomcat application could collect and send the request parameters to your script and/or "web application" running in the background.

Categories : Multithreading

Blocking SSL_read() causes a crash when partner closes connection, using threading
It is unclear what you are really doing. Blocking SSL_read together with threads is not a problem by itself. Maybe you should read the relevant part about threads in the OpenSSL FAQ. Especially the following part might be relevant for you: ... an SSL connection may not concurrently be used by multiple threads

Categories : Multithreading

Using the Delphi XE7 Parallel Library
The most obvious problem that I can see is that you queue to the worker thread. Your call to TThread.Queue passes TThread.CurrentThread. That is the very thread on which you are calling TThread.Queue. I think it is safe to say that you should never pass TThread.CurrentThread to TThread.Queue. Instead, remove that parameter. Use the one parameter overload that just accepts a thread procedure.

Categories : Multithreading

Do I need a mutex on a vector of pointers?
Every thread is appending different std::vector (inside AppendToVector function) so there is no need for locking in your case. In case you change your code in the way more than one thread access same vector then you will need lock. Don't be confused because std::vectors you are passing to AppendToVector are them-selfs elements of main std::list, it matters only that here threads are manipulating

Categories : Multithreading

Best way to synchronize two threads with each other in Delphi
When I find myself in situations like this, I like to use Windows events. They are exposed in Delphi using a TEvent class, which you WaitForSingleObject. So, you could use two events: Thread1NotActive and Thread2NotActive. Once Thread1 is done, it sets the Thread1NotActive flag, which is waited on by Thread2. Conversely, if Thread2 stops processing, it sets Thread2NotActive, which is monitored by

Categories : Multithreading

Nested "for" loop divided by threads
Sorry, it's a bit hard to read the code with the cryptic words in, I'm guessing, Polish or Czech. One of the solution is to separate the image in parts and apply to algorithm you showed in your snippet to each part independently. This comes down to splitting your array into parts. So, if you have an array of 300 pixels and 3 threads, each thread will get his own 100 pixels which will be turned in

Categories : Multithreading

What is the difference between Runnable and Future in Scala?
A Future is 'a container' for something which runs async (it's a monad). So, you get a toolbox to handle the computation result / failures. Have you read this: http://docs.scala-lang.org/overviews/core/futures.html ?

Categories : Multithreading

Difference between MP and SP (or is it Cuda Core) in thread parallelism?
Each Grid of Blocks executes on a single device. (e.g Device has 9 MP) Correct. Each Block of Threads executes on a single MultiProcessor. (e.g 1 MP has 8 SP/Cores). Thread blocks are separately scheduled onto SMs, and threads within a given block are executed by the same SM. Each Block of Threads executes on a single MultiProcessor. (e.g 1 MP has 8 SP/Cores). Right. A thread

Categories : Multithreading

Cuda: If I use only .x of block and threads, will it still use all available threads in GPU or for that using .y and .z of thread and block is a must?
The CUDA threads hierarchy is just a convenience abstraction and there's no requirement for using one, two or three dimensions, nor you will lose performances if you just use one dimension instead of all three of them. You will be able to use all the threads you launched with a set of indices as long as you specified the correct grid dimension. 2.2. Thread Hierarchy For convenience, threa

Categories : Multithreading

Executing Gtk.ListBox.insert and Gtk.ListBox.append in another thread causes Vala program to segfault
All calls to GDK and GTK+ should be made from the main thread. This is quite easy to do with Vala by using GLib.Idle.add, especially if you keep in mind that Vala supports closures: // Do stuff in your thread (CPU-intensive processing, I/O, etc.) var value = blocking_operation (); GLib.Idle.add (() => { // You can access local variables, like value, here. widget.set_something (value)

Categories : Multithreading

Different way to index threads in CUDA C
A common way to have a smaller number of threads cover a larger number of data elements is to use a "grid-striding loop". Suppose I had a vector of length n elements, and I had some smaller number of threads, and I wanted to take every element, add 1 to it, and store it back in the original vector. That code could look something like this: __global__ void my_inc_kernel(int *data, int n){ int

Categories : Multithreading

What's the difference between async methods and threads?
Threads are independently schedulable while async methods run in the main thread, that is, they are coroutines. For example, if you block reading a socket in a separate thread, the application can continue running, but if you do this in an async method, the application will block. Threads and coroutines (async methods) can solve some of the same problems, but are generally doing different things.

Categories : Multithreading

How do I invoke a command in a Tcl thread asynchronously from a non-tcl thread?
Tcl_ThreadQueueEvent and Tcl_ThreadAlert is what I've used in the past. You need to remember the thread id of the Tcl main thread for the alert call using Tcl_GetCurrentThread. There is an example in tmsWinMailslot if you look at the MailslotSignalledProc which raises Tcl events from a worker thread that is monitoring the Windows mailslot in this code. Its using Windows overlapped I/O so once som

Categories : Multithreading

How detach repl from starting terminal/thread?
You might want to try bourdeaux-threads, for example: (defun start () (bt:make-thread #'(lambda () (start-my-repl))) (start-qt-app))

Categories : Multithreading

How To Test In XCode That A Process Is Running On A Background Thread?
First: A process is the one that contains multiple threads, so a process can never run on a background thread as it is the one that contains all the threads. Now to your problem of communicating between threads: AFNetworking is build on top of NSOperation and NSOperationQueue. Each request is an operation running in an operation queue. This means every request is always running on a background qu

Categories : Multithreading

Getting LazyInitializationException "could not initialize proxy - no Session" when running a transaction in a background thread
1) You need a readOnly transaction to get lazy collections. 2) I suppose that @Transactional doesn't work on your local methods because when you call a local method you call the implementation directly, not a proxy object created by Spring. If it's the case there are at least 2 choices: 1) Switch to Aspectj <tx:annotation-driven mode="aspectj" proxy-target-class="true"/> 2) Create a tr

Categories : Multithreading

How does jsp ensure thread safety?
JSP will not ensure thread safety by the technology. You must code the threadsafety in the JSP yourself. Sometimes the container implements thread-safety under special conditions, by technology: if one port for only one request without multiplex and without portredirection.

Categories : Multithreading

Can't create thread in vala: `GLib.Thread' does not have a default constructor
As specified in the sample, you have to build using the option --target-glib 2.32 The complete build line is: valac <your vala file> --target-glib 2.32

Categories : Multithreading

Perl Threads Excessive Memory Usage
As mentioned in the comments - there's no obvious leaks here. You've avoided some of the key 'gotchas' with thread programming by running 'worker' threads from a queue. I would suggest you need to look at what's happening with your your database calls and your object creating in the processJob sub. Common traps in OO is to create a circular reference within an object, so even when the object

Categories : Multithreading

Threading issue with UICollectionview loading images from CloudKit
before returning self.numberOfItemsInSection you should wait until the async call is finished. You can do that using semaphores. But then why are you doing this async? You are just getting the count of an array. And then you shouldn't reloadData there. Where do you start your CloudKit query? are you doing that onViewDidLoad? That is also an async operation. When that completes just doe a reloadDat

Categories : Multithreading

Use threads on a RESTful Web Service in Java
Sure, it is possible. Are you familiar with concurrent API offered by Java? At an high level point of view, you have to write the code that handles that Http POST. In this code, you can instantiate an arbitrary number of threads (a thread pool), and each thread of the pool makes the update on a subset of the rows to update. For example you can start 10 threads and each thread make the update on j

Categories : Multithreading

Shared socket object among Perl threads
Can I suggest instead that you don't try and share a socket between threads? That feels like something that's going to be asking for concurrency issues between them. Whilst there are (probably) ways of doing that, I'd suggest instead - have a single thread 'responsible' for the IO, and use something like Thread::Queue to interact with it. E.g. something like: use strict; use warnings; use t

Categories : Multithreading

Why sequentiall threads execution is called synchronous?
In case of Synchronous they are accessing the resources in a nice manner. (waiting in a queue) --good In case of Asynchronous (not Synchronous) they act like barbarian and just only think about their selves and try to access resource with out thinking of others.--not good In case of the Java Threads, the Documentation says: Threads communicate primarily by sharing access to fields and the obj

Categories : Multithreading

Customizing a name of a thread in camel
See http://camel.apache.org/threading-model.html: <camelContext xmlns="http://camel.apache.org/schema/spring" threadNamePattern="Riding the thread #counter#"> <route> <from uri="seda:start"/> <to uri="log:result"/> <to uri="mock:result"/> </route> </camelContext>

Categories : Multithreading

cudaDeviceSynchronize() waits to finish only in current CUDA context or in all contexts?
When I call cudaDeviceSynchronize(); will it wait for kernel(s) to finish only in current CUDA context which selected by the latest call cudaSetDevice(), or in all CUDA contexts? cudaDeviceSynchronize() will only synchronize host with the currently set GPU, if multiple GPUs are in use and all need to be synchronized, cudaDeviceSynchronize() has to be called separately for each one. Here

Categories : Multithreading

Rust syncronization strategy for MUD server
An Arc will let you access a value from multiple tasks, but it will not allow you to borrow the value mutably. The compiler cannot verify statically that only one task would borrow the value mutably at a time, and mutating a value concurrently on different tasks leads to data races. Rust's standard library provides some types that allow mutating a shared object safely. Here are two of them: Mut

Categories : Multithreading

Allocating Multiple Threads to Single Parallel Do on Xeon Phi with Open MP
KMP_PLACE_THREADS will set OMP_NUM_THREADS implicitly, so you don't need to specify this in your mic environment variables. If you would like to use 59 tasks with 4 threads per task you have a few options. MPI/OpenMP As you mentioned, you could use a hybrid MPI/OpenMP approach. In this case you will utilise a different OpenMP domain per rank. I achieved this in the past running mpirun nativel

Categories : Multithreading

How to access Outlook email by a Delphi subthread
Where is your code running? Is it a standalone exe or a COM addin? Keep in mind that Outlook 2013 will raise an exception as soon as it detects that is object is being used rom a thread other than its main thread (in case of a COM addin). In case of a standalone exe, all calls are marshaled to the main Outlook thread anyway, so you are not gaining anything by using secondary threads. You can use

Categories : Multithreading

Do I need to use a thread? GUI + simple web scraping
If you want your GUI to be responsive while it's downloading things from the web, then absolutely you need threads. You need one for the GUI, and one for background network access. If you don't do this, then you'll find that your application will lock up while it's doing its network thing. You'll probably still be able to move the window around, but it won't redraw itself or respond to any clicks

Categories : Multithreading

How to restart child process with Parallel::ForkManager on finish
I think you're misunderstanding what's happening. Under the covers, what Parallel::ForkManager is doing is calling a fork(). Two processes exist at this point, with only a single difference - different PIDs. Your child process goes and runs some stuff, then exits, generating an exit status, which your parent then reaps. Restarting the process... well, you just need to fork again and run your c

Categories : Multithreading

GCD dispatch_sync priority over previously queued dispatch_async
There's not a generic setting for "perform sync tasks first" or for setting relative priority between enqueued blocks in a single queue. To recap what may be obvious, a serial queue is going to work like a queue: first in, first out. That said, it's pretty easy to conceive of how you might achieve this effect using multiple queues and targeting. For example: realQueue = dispatch_queue_create(NULL

Categories : Multithreading

How kernel treats two user level threads?
Can two user level threads of same process run simultaneously on multi core CPU? Yes, one of the main reasons to use threads is to increase performance by working concurrently on independent computations. If yes, is it done by kernel or library function? The kernel is responsible for managing the resources provided by the hardware, including the multiple cores in a multi core CPU. The

Categories : Multithreading

Why am I getting deadlock when using semaphores in recursive functions calls
I don't know why it hangs but the fix would be: func doSynchronousHTTPGetRequest(url: String, completionHandler: (NSData!, NSURLResponse!, NSError!) -> Void) { if let url = NSURL(string: url) { let semaphore = dispatch_semaphore_create(0); var _data:NSData! var _response:NSURLResponse! var _error:NSError! let task = NSURLSession.sharedSession().dat

Categories : Multithreading

Calling a subroutine in FORTRAN without blocking the main program
I would use a POSIX thread for this. Maybe also an OpenMP task, but my experience with them is limited. I will assume you do not call any MPI procedures in the child. With a simple interface in C #include <pthread.h> void pthread_create_opaque(pthread_t *threadptr, void *procptr, void *dataptr, int *err){ // creates a new thread using an opaque pointer to the pthread_t structure *err

Categories : Multithreading

Update UI using Parallel Task
In any function in your Form or UserControl, you can use the following type of code: public void SetText(string text) { if (InvokeRequired) { BeginInvoke(new Action<string>(SetText), text); } else { label1.Text = text; } } label1 would be the control to update in this case. This will make sure that you invoke the function on the UI-thread. You shoul

Categories : Multithreading




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.