Posted by
Daisy Williams
Mar
8
The java.lang.Thread class is used to define a thread. The simplest way to create a thread by using the java.lang.Thread class is to take the following two steps:
Extend the java.lang.Thread class.
Override the run() method.
The extending class must override the run() method, which is the entry point of the new thread. The extending class calls the start() method to begin the execution of the new thread, as shown below:
class MyThread extends Thread
{
public void run()
{
System.out.println(”thread running”);
}
}
The major limitation of this approach is that if Thread is extended, the programmer will not be able to extend anything else.
Permanent link to this post (107 words, estimated 26 secs reading time)
Filed under:
UncategorizedFiled under: Uncategorized
Posted by
Daisy Williams
Mar
7
The getStatus() method of the UserTransaction interface returns the status of the current transaction. Since this method is present in the UserTransaction interface, it can be called only for a BMT bean, but not for a CMT bean. This method can be used to find out whether or not a transaction has been marked for a rollback. If this method is called on a thread that has no transaction associated, it returns the Status.NoTransaction value.
Permanent link to this post (76 words, estimated 18 secs reading time)
Posted by
Daisy Williams
Mar
6
The equals() method checks if some other object passed to it as an argument is equal to the object on which this method is invoked. The default implementation of the equals() method is in the Object class, the mother of all classes in Java. The equals() method in the Object class checks if two object references refer to the same object, i.e., it checks the referential equality of the two object references. This comparison is also known as shallow comparison.
Posted by
Daisy Williams
Mar
5
The begin() method creates a new transaction and associates it with the current thread. This method belongs to the UserTransaction interface. The general form of this method is as follows:
public abstract void begin() throws IllegalStateException
This method will throw an IllegalStateException if the thread is already associated with a transaction.
Permanent link to this post (52 words, estimated 12 secs reading time)