Get Hired

Jobs from Indeed

Sunday, March 25, 2018

Multithreading : Part 12 - Synchronization


A small java program to understand the need of synchronization.

Multithreading : Part 11 - Synchronization needed in real life



When there are many threads trying to access one shared resource, and are trying to fight over priorities, it isn’t good for your program. You might face inconsistency issues or unexpected thread interference.
To make sure a resource is being used by just one thread at a time, we make use of synchronization.
Just imagine this as a snack someone offers to you and your family when you visit their house. Each person in the room is a thread, and that delicious snack in the middle is a shared resource. Now wearing a mask of a good lad you are supposed to allow everyone to get a piece of it. That’s you and your siblings behaving in a synchronized way. That’s what synchronization in Java is about too.

Wednesday, March 14, 2018

How to create executable jar file

https://youtu.be/ex2TtJ_9aIk

Multithreading : Part 10 : create thread with Runnable

https://youtu.be/hEeb-NN0nb4

Multithreading : Part 9 : create thread

https://youtu.be/_FmskGFrEvg

https://youtu.be/_FmskGFrEvg

https://youtu.be/_FmskGFrEvg

Thread vs Runnable

Java lets you create thread in following two ways:-
By implementing the Runnable interface.
By extending the Thread
Let’s see how both the ways help in implementing Java thread.
Runnable Interface
The easiest way to create a thread is to create a class that implements the Runnable interface.
To implement Runnable interface, a class need only implement a single method called run( ), which is declared like this:
public void run( )
Inside run( ), we will define the code that constitutes the new thread.
Example:
public class MyClass implements Runnable {
public void run(){
System.out.println("MyClass is running");
}
}
To execute the run() method by a thread, pass an instance of MyClass to a Thread in its constructor as follows:
Thread t1 = new Thread(new MyClass ());
t1.start();
When the thread is started it will call the run() method of the MyClass instance instead of executing its own run() method. The above example would print out the text “MyClass is running“.
Extending Java Thread
The second way to create a thread is to create a new class that extends Thread, then override the run() method and then to create an instance of that class. The run() method is what is executed by the thread after you call start(). Here is an example of creating a Java Thread subclass:
public class MyClass extends Thread {
public void run(){
System.out.println("MyClass is running");
}
}
To create and start the above thread you can do like this:
MyClass t1 = new MyClass ();
t1.start();
When the run() method executes it will print out the text “MyClass is running“.

Thread vs Runnable

https://youtu.be/mtiZVJDL0w0

Sunday, March 11, 2018

How to set background image

How to send image in background of JFrame

Some midifmodifica to make the image in center

A different way to set background image, that can resize the image with the size of JFrame to fill the entire region.

Wednesday, March 7, 2018

Unzip a file using Java

I have uploaded a video to explain, that how can we unzip or decompress a zip file. Jus follow the link below, learn and enjoy.