How-to articles, tricks, and solutions about MULTITHREADING

"implements Runnable" vs "extends Thread" in Java

In Java, you can create a thread in two ways: by implementing the Runnable interface or by extending the Thread class.

Difference between "wait()" vs "sleep()" in Java

In Java, the wait() method is used to pause the current thread and allow other threads to execute. It is called on an object and causes the current thread to wait until another thread calls the notify() or notifyAll() method on the same object.

How can I pass a parameter to a Java Thread?

To pass a parameter to a Java thread, you can use a Runnable object and pass the parameter to its constructor.

How can I use threading in Python?

Threading is a way to run multiple threads (smaller units of a program) concurrently, in the same process.

How do you kill a Thread in Java?

To stop a thread in Java, you can use the interrupt() method of the Thread class.

If statement with String comparison fails

If an if statement with a string comparison fails in Java, it usually means that the strings being compared are not equal.

What does 'synchronized' mean?

In Java, the synchronized keyword is used to provide mutually exclusive access to a shared resource. When a thread tries to execute a synchronized block of code, it will first acquire a lock on the object that the code is synchronized on. If another threa

What is a daemon thread in Java?

In Java, a daemon thread is a thread that runs in the background and does not prevent the program from exiting.

What is thread safe or non-thread safe in PHP?

In PHP, a thread-safe version of PHP is built with additional constructs to ensure that certain actions are atomic, which means that they are performed in their entirety without any other thread being able to interfere.