Situation:
I am writing a program in C that maintains a number of threads. Once a thread ends, a new one is created.
Each thread forks - the child runs a PHP process via exec() and the parent waits for it to finish.
Each PHP process takes the next item from a queue, processes it and exits.
Basic code: http://www.4pmp.com/2010/03/mu...
In Java, I want to download some data asynchronously in a Thread (or Runnable) object, and have the Thread put it's data into an Object I've declared within my main Thread.
How could I do this please?
...
Are there any .NET classes/functions that are optimized for multiple cores?
I know that the developer is supposed to do this himself/herself. But seeing how we are getting CPUs with more and more cores and there are still many developers who do not use multithreading, if we have this functionality built in, it could increase performance...
I was thinking about a way to allow multiple users to get CRUD access to an XML document in an asp.net app. The operations would obviously have to be made under the assumption of a multithreaded environment.
For perf reasons, would it make sense to cache the document, and use a mutex on that cached version? When would changes be flush...
We have a WinForms desktop application, which is heavily multithreaded. 3 threads run with Application.Run and a bunch of other background worker threads. Getting all the threads to shut down properly was kind of tricky, but I thought I finally got it right.
But when we actually deployed the application, users started experiencing the...
I am trying to serealize DataTables in a background thread and it's failing. Any idea
[Test]
public void Async_Writing_DataTables()
{
string path = @"C:\Temp\SerialzeData";
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
Assert.IsTrue(Directory.Exists(path...
I have a managed thread which is waiting, blocked, in an unmanaged code (specifically, it on a call to NamedPipeServerStream.WaitForConnection() which ultimitely calls into unmanaged code, and does not offer a timeout).
I want to shut the thread down neatly.
Thread.Abort() has no effect until the code returns to the managed realm, whic...
I have what I think is a rather complex problem. I have a C# application that utilizes a plug-in architecture using reflection. The application loads plug-in dlls and the user is able to enable/disable them. When a plug-in is enabled, the main app starts a thread to run the plug-in in. In many cases the plug-in may have multiple thre...
Would be thread-safe to use the yield operator inside an extension method?
For example:
public static IEnumerable<CartItem> GetItems( this Cart cart )
{
{
while( cart.hasNext() )
yield return cart.GetNextItem( );
}
}
...
My application spawns loads of different small worker threads via ThreadPool.QueueUserWorkItem which I keep track of via multiple ManualResetEvent instances. I use the WaitHandle.WaitAll method to block my application from closing until these threads have completed.
I have never had any issues before, however, as my application is comin...
I have no idea why this is hanging. I'm trying to capture output from a process run through commons-exec, and I continue to hang. I've provided an example program to demonstrate this behavior below.
import java.io.DataInputStream;
import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import org.a...
i use this code can crteate ,but someone say it can't create ,why ?
class LogText(db.Model):
content = db.StringProperty(multiline=True)
class MyThread(threading.Thread):
def __init__(self,threadname):
threading.Thread.__init__(self, name=threadname)
def run(self,request):
log=LogText()
log.content=...
from threading import Timer
def hello():
print "hello, world"
t = Timer(30.0, hello)
t.start()
This code only fires the timer once.
How can I make the timer run forever?
Thanks,
updated
this is right :
import time,sys
def hello():
while True:
print "Hello, Word!"
sys.stdout.flush()
time.sleep(2.0...
Okay, so if I'm running in a child thread on linux (using pthreads if that matters), and I run the following command
kill(getpid(), someSignal);
it will send the given signal to the parent of the current thread.
My question: Is it guaranteed that the parent will then immediately get the CPU and process the signal (killing the app if ...
Hi to all! I have an interesting (to me) problem... There are two threads, one for capturing data from std input and sending it through socket to server, and another one which receives data from blocking socket. So, when there's no reply from server, recv() call waits indefenitely, right? But instead of blocking only its calling thread, ...
If a thread holds a lock , what happens when the thread needs to enter another critical section controlled by the same lock?
...
I use Axis for webservice service.
when more than 8 concurrent , there are some request halt randomly for about 30 seconds.
I debug by log in every line and found from my code:
public class foo{
void bar(){
a();
log.debug('exit from a');
}
void a(){
log.debug('exit a');
}
th...
I'd just like to know if it's advised to return from a method within a @synchronized block? For example:
- (id)test {
@synchronized(self) {
if (a) return @"A";
else return @"B";
}
}
As opposed to:
- (id)test {
NSString *value;
@synchronized(self) {
if (a) value = @"A";
else value = @"B";
}
re...
There's a weird behavior in my threads:
void * foo(void * nic){
printf("foo");
}
void * threadF(void * pointer){
printf("1\n");
pthread_t threadT;
pthread_attr_t attr;
pthread_attr_init (&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
pthread_create(&threadT,NULL,&foo,(void*)NULL);
pr...
I have heard that the .NET 4 team has added new classes in the framework that make working with threads better and easier.
Basically the question is what are the new ways to run multithreaded tasks added in .NET 4 and what are they designed to be used for?
UPD: Just to make it clear, I'm not looking for a single way of running parallel...