Posts

ORM features in hibernate

Image
Hibernate is Object Relational Mapping(ORM) framework. Hibernate has the advantages while comparing with JDBC. That advantages will make developer life will be easy were implementing or maintaining the java application. Hibernate ORM features are, Hibernate gives the support of POJO/POJI model programming. It is also API independent. Light weight technology, no need of web or application servers. No byte code enhancement like EJB. Supports inheritance and polymorphism features. EJB component do not support inheritance. Pluggable with any Java/JEE or framework software based applications. The persistence logic of hibernate application can be access from all type of java client application. Gives implicit middleware services like jdbc connection pooling, transaction management etc.., Gives support to work with third party jdbc connection pooling. Support to call stored procedures and functions. Supports database indepen...

Thread priority in java with example

Thread priority is useful to maintain threads in an order in java. When multiple threads are created and started, a 'Thread Scheduler' program will load all threads into JVM memory and executes them based on thread priority. This scheduler will allot more JVM time to those threads which are having higher priorities.           The priority number of a thread will change from 1 to 10. The minimum priority ( Thread.MIN_PRIORITY ) of a thread is 1, and the maximum priority ( Thread.MAX_PRIORITY ) is 10. The normal priority of a thread ( Thread.NORM_PRIORITY ) is 5. Example: Let us write a program to understand the thread priority. The thread with higher priority number will complete its execution first. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 package com . javatbrains . threads ; class ThreadPriority extends Thread { int count = 0 ; publi...

Multithreading in java with example

Multithreading  is one of the most important concept in core java. In this article we will learn what is multithreading? , what is the use of it? and What is the use of Synchronization and when to use it?  with detailed examples. At a time, two or more threads are accessing the same object is called as Multithreading  in Java .  First, we will create two threads for two objects. It is also possible to run two or more threads on a single class object. In this case, there is a possibility to get unreliable results. If the two threads are perform same task, then they need same object to be executed each time. For your better understanding, take an example of any reservations like, railway, movie ticket booking,etc. Let us think only one berth is available in a train and two passengers are asking for that berth. The first person has sent a request to allocate that ticket/berth to him. At the same time, the second person also sent a request to allocate that ...

how to create our own thread in java with example

To create user defined thread in java, create a class that extends Thread or implements Runnable interface. Both of the Thread class and Runnable interface are available in java.lang package. class MyClass extends Thread OR class MyClass implements Runnable         •   Now in this class, write a run() method as, public void run (){ statements ; }        by default, this run() method is recognised and executed by a thread when you started a thread.        •    Create an object of MyClass, So that the run() method is available for execution. MyClass obj = new MyClass ();       •    Now, Create a thread and attach the thread to the object obj. Thread t = new Thread ( obj );       •    Run the thread. For this purpose, we should use start() method of Thread class. t ...