Hello,
I have simple from written on C/gtk+ and i have function in this appliction. I need to run this function in a separate thread from gui form. Where can i see example?
Thank you.
I'm looking for a quick bash script or program that will allow me to kick off a python script in a separate thread. What's the best way to do this? I know this is incredibly simple, just curious if there's a preferred way to do it.
Yes, I'm being lazy.
What happens when I call performSelector:onThread:... and pass in a thread that's currently blocked (on synchronous I/O, for instance)? Does the selector just get queued to be executed later?
According to the C++0x final draft, there's no way to request a thread to terminate. That said, if required we need to implement a do-it-yourself solution.
In your opinion, what's the best solution? Designing your own cooperative 'interruption mechanism' or going native?
I have scheduled a CRON job to run every 4 hours which needs to gather user accounts information.
Now I want to speed things up and to split the work between several processes and to use one process to update the MySQL DB with the retrieved data from other processes.
In JAVA I know that there is a thread pool which I can dedicate some threads to accomplish some work.
how do I do it in PHP?
Any advice is welcome.
Thank
Is there any way I can have a thread branch off into its own independent process? I know there's the CreateProcess function but as far as I can tell, you can only run external applications with it. Is what I'm asking for at all possible?
I'm trying to do the same thing as suggested in this solution:
http://stackoverflow.com/questions/164496/how-can-i-create-a-thread-safe-singleton-pattern-in-windows/164640#164640
But, where should the critical section be initialized and uninitialized?
I'm going to reuse OGNL library out of Struts2 scope. I have rather large set of formulas, that is why I would like to precompile all of them:
Ognl.parseExpression(expressionString);
But I'm not sure if precompiled expression can be used in multi-thread environment. Does anybody knows if it can be used?
In what circumstances would updating a UI control from a non-UI thread could cause the processes' handles to continually increase, when using a delegate and .InvokeRequired?
For example:
public delegate void DelegateUIUpdate();
private void UIUpdate()
{
if (someControl.InvokeRequired)
{
someControl.Invoke(new DelegateUIUpdate(UIUpdate));
return;
}
// do something with someControl
}
When this is called in a loop or on timer intervals, the handles for the program consistently increase.
does anyone know what part of the opengl es thread on an android device runs on the gpu (if it has one). just the method calls you make with the GL10 adapter class? or the complete onDraw method in your custom Renderer class?
HI,
During the development of my app, I was using Thread.Sleep to give our external devices some time to adjust to settings before making queries, as they are quite old and slow.
I now want to replace these with something a bit more stylish and correct.
Does anyone have a simple way to "wait" for a device rather than sleep, bearing in mind the device does not let us know when it is ready, so a wait is about as good as we can do !??
Regards, George.
Is there a way to see how many context switches each thread generates? (both in and out if possible) Either in X/s, or to let it run and give aggregated data after some time.
(either on linux or on windows)
I have found only tools that give aggregated context-switching number for whole os or per process.
My program makes many context switches (50k/s), probably a lot not necessary, but I am not sure where to start optimizing, where do most of those happen.
Yes, the private member variable bar should be final right? But actually, in this instance, it is an atomic operation to simply read the value of an int. So is this technically thread safe?
class foo {
private int bar;
public foo(int bar) {
this.bar = bar;
}
public int getBar() {
return bar;
}
}
// assume infinite number of threads repeatedly calling getBar on the same instance of foo.
When I link Boost.Thread to my boost_test executable, it gives me
make[2]: *** No rule to make target `/usr/lib64/libboost_thread-mt.so', needed by `gogo/test/test_boost'. Stop.
when I make it. Here's the offending CMake code, what am I doing wrong?
add_executable(boost_test boost_test.cpp)
add_test(boost_test boost_test)
# Boost auto-links for MSVC, so we exclude it.
if(CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries(test_boost #LINK_INTERFACE_LIBRARIES
${Boost_THREAD_LIBRARY}
)
endif()
Class Test{
int value;
static void* thread_func(void* args){
value++;
}
void newthread(){
pthread_create(&thread_func,...);
}
}
I'm trying to create a thread in Class Test. Therefore compiler forces me to make thread_func static. However I cannot access the non-static member "value" anymore. It says:
invalid use of member 'Class::value' in static member function
Is there a way around it?
Hey guys
i just have two questions about two methods used in many controllers/servlets in my app:
1-what is the difference between calling a static method in a util class or a non static method (like methods dealing with dates i.e getting current time,converting between timezones), which is better ?
2-what is the difference between calling a method(contain too many logic like sending emails) in the controller directly or running this method in a different thread ?
Is there any way i can have a thread branch off into it's own independent process? I know there's the CreateProcess function but as far as I can tell, you can only run external applications with it. Is what I'm asking for at all possible?
Hello I have some code that is cross-platform by unsing #ifdef OS,
I have a Queue protected by a CriticalSection on Windows, and by a pthread_mutex_t on Linux.
I would like to implement a Wait(timeout) call that would block a thread until something has been enqueued. I though about using WaitForSingleObject on windows but it don't seem to support CriticalSection. Which Win32 and which Linux functions should I use to Wait and Signal for a condition to happen.
Thank
Hello,
I've read somewhere that when a session is flushed or a transaction is committed, the session itself is closed by Hibernate. So, how can i reuse an Hibernate Session, in the same thread, that has been previously closed?
Thanks
consider this class,with no instance variables and only methods which are non-synchronous can we infer from this info that this class in Thread-safe?
public class test{
public void test1{
// do something
}
public void test2{
// do something
}
public void test3{
// do something
}
}
Is ResultSet Thread safe?
My question arises because in this i have used a different statement for each query i have delsared a ResultSet as an local variable but it gives me a error of Operation not allowed after ResultSet is closed. But my statements are working as i'm using the statements in insert and delete query.I have commented the ResultSet part and have not got the error !!
The source code of my program can be referd to , in my earlier Question .
I'm currently using the following code for thread-safe access of a variable.
int gnVariable;
void getVariableValue(int *pnValue)
{
acquireLock(); //Acquires the protection mechanism
*pnValue = gnVariable;
releaseLock(); //Releasing the protection mechanism
}
I would like to change my API signature to a more user-friendly
int getVariableValue(void);
How should I rewrite the function - such that the users of the API don't have to bother about the locking/unlocking details?
What would be the least-slow thread-safe mechanism for controlling multiple accesses to a collection in Java?
I am adding objects to the top of a collection and i am very unsure what would be the best performing collection. Would it be a vector or a queue? I originally thought an ArrayList would be fast but i ran some experiments and it was very slow.
EDIT: In my insertion testing a Vector delared using volatile seems to be the fastest?
I there any method to sleep the thread upto 100.8564 millisecond under window OS. I am using multimedia timer but its resolution is minimum 1 second. Kindly guide me so that I can handle the fractional part of the milisecond.