Threads are used to to run multiple programs simultaneously. Primarily, Threads execute a given program.
There are two ways to create threads extends and implements
- extends Thread class cannot extend any other classes
- implements Thread class can extend to other classes
Extends
public class Example extends Thread {
public static void main(String[] args) {
// Creating thread
Example thread = new Example();
// Running the thread
thread.start();
System.out.println("Main Program");
}
public void run() {
System.out.println("This is the Thread");
}
}
Implements
public class Example implements Runnable {
public static void main(String[] args) {
// Object Constructor
Example Object = new Example ();
// Creating new thread
Thread thread = new Thread(Object );
// Starting Run
thread.start();
System.out.println("Main Program");
}
public void run() {
System.out.println("This is the Thread");
}
}
Android Studio Loading Animation Between Activities
Progress Dialog is dialog showing a progress indicator and an optional text message or view. The methods of Progress Dialog being used in this tutorial are: ProgressDialog.setTitle() – Used to set title of dialog box ProgressDialog.setMessage() – Used to set dialog message being displayed ProgressDialog.setProgressStyle() – Choose the style of indicator ProgressDialog.dismiss() – Dismiss the…
Android Studio Tutorial SeekBar
SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch thumb and drag left or right to set the current progress level or various other task. In this example, the seekbar will be used to display a percentage. As the user moves the SeekBar left to right the percentage value…
Python Ethereum Block Chain Interaction with Web3
This tutorial will show how to interact with the Ethereum blockchain using Python. To start, the Python library Web3 will need to be installed. The Web3 library allows you to interact with a local or remote Ethereum node, using a HTTP or IPC connection. Using Web3 you will be able to create smart contracts on…