View RSS Feed

Recent Blogs Posts

  1. Using threads in Java applications

    by , 04-03-2012 at 11:57 AM
    Are you going to code a Java application that processes multiple tasks at the same time? Or is your program doing some heavy operations in the background, while the user is viewing a chart report? Such applications are referred as multi-threaded or concurrency programs. The Java platform has built-in support for threading from its very early versions, so developing multi-threaded applications in Java is not tough at all, thanks to the comprehensive and powerful threading and concurrency API. ...
    Tags: java, thread, tutorial Add / Edit Tags
    Categories
    Tutorial
  2. High-level thread states

    by , 01-08-2012 at 12:16 PM
    Following diagrams display different thread states.

    Name:  62.JPG
Views: 785
Size:  29.7 KB

    Thread States

    • Runnable: Thread in this state is waiting for its turn to start execution.
    • Running: Thread is executing and performing its functionality.
    • Waiting: Thread is in blocked state and waiting for some operation to finish.
    • Sleeping: Thread is suspended forcefully.
    • Blocked on I/O: Thread will start execution after completion of ...
    Tags: states, thread Add / Edit Tags
    Categories
    Tutorial
  3. Thread priorities, synchronization and messaging

    by , 11-13-2011 at 10:47 AM (My Java Tips)
    I assume that you have the basic knowledge of threads. In this post, I will write about thread priorities, synchronization and messaging.


    In multithreading environment, one thread might require the attention of the CPU more quickly than other. In such a case that thread is said to be of high priority. Priority of a thread determines the switching from one thread to another. In other words, priority determines how a thread should behave with respect to the other threads.
    ...
  4. Creating a Thread (extending Java Thread Class)

    by , 11-13-2011 at 10:41 AM (My Java Tips)
    There are two ways to create a new thread of execution. One is to declare a class to be a subclass of Thread. This subclass should override the run method of class Thread. An instance of the subclass can then be allocated and started. The other way to create a thread is to declare a class that implements the Runnable interface. That class then implements the run method. An instance of the class can then be allocated, passed as an argument when creating Thread, and started.


    In case, ...
  5. Creating a Thread (implementing Java Runnable Interface)

    by , 11-12-2011 at 05:58 PM (My Java Tips)
    A better way to create a thread in Java is to implement Runnable interface. A thread can be created by extending Java Thread class also. Now the question arises why implementing Runnable interface is a better approach? Answer is, if the thread class you are creating is to be subclass of some other class, it can’t extend from the Thread class. This is because Java does not allow a class to inherit from more than one class. In such a case one can use Runnable interface to implement threads.
    ...
  6. Threads In Java

    by , 11-08-2011 at 06:43 PM (My Java Tips)
    Threads are small processes that are part of a larger process. A single process may have many threads and even if one of these threads is waiting for input from the user or is blocked or is carrying out a lengthy process, the rest of the threads can continue. An example of this can be a word processor which is a process with many threads such as the spell checker, the grammar checker, the user typing area etc.In Java, thread is just the path of execution.
    In Java, threads are created by two ...
    Tags: sleep, thread Add / Edit Tags
    Categories
    Java SE
  7. Threads and Monitors in Eclipse

    by , 05-21-2011 at 10:40 PM (My Java Tips)
    When you are working with multi threading where resources are locked and released, deadlock prevention becomes very important. To prevent starvation, proper lock and release mechanism has to be defined/implemented.

    Eclipse’s debugger provides monitor information in the debug view. To use it, use the Show Monitors action which can be found in the Debug view drop down menu. It will show which threads are holding locks and which are waiting to acquire locks. The threads in red indicated ...
    Categories
    Eclipse