How do I update the GUI from another thread?

The simplest way is an anonymous method passed into Label.Invoke: // Running on the worker thread string newText = “abc”; form.Label.Invoke((MethodInvoker)delegate { // Running on the UI thread form.Label.Text = newText; }); // Back on the worker thread Notice that Invoke blocks execution until it completes–this is synchronous code. The question doesn’t ask about asynchronous … Read more

What is the difference between a process and a thread?

Both processes and threads are independent sequences of execution. The typical difference is that threads (of the same process) run in a shared memory space, while processes run in separate memory spaces. I’m not sure what “hardware” vs “software” threads you might be referring to. Threads are an operating environment feature, rather than a CPU … Read more

C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?

First, you have to learn to think like a Language Lawyer. The C++ specification does not make reference to any particular compiler, operating system, or CPU. It makes reference to an abstract machine that is a generalization of actual systems. In the Language Lawyer world, the job of the programmer is to write code for … Read more

“implements Runnable” vs “extends Thread” in Java

Yes: implements Runnable is the preferred way to do it, IMO. You’re not really specialising the thread’s behaviour. You’re just giving it something to run. That means composition is the philosophically “purer” way to go. In practical terms, it means you can implement Runnable and extend from another class as well… and you can also … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)