Month: November 2017

Threads  in Java ..

Posted on Updated on

Threads  in Java

Java is a multi-threaded programming language which means programmer  can develop multi-threaded program using Java. A multi-threaded program contains two or more parts that can run simultaneously (concurrently) and each part can execute a different code  at the same time making maximum use of the available resources. Resources mean available CPU time or memory or both.

Process vs. Thread 

To understand concurrency and multi threading, one must first understand differences between a process and a thread.

process runs independently and isolated of other processes. It cannot directly access shared data in other processes. The resources of the process, e.g. memory and CPU time, are allocated to it through  the operating system.

thread is a so called lightweight process. It has its own call stack (order in which various methods are called), but can access shared data of other threads in the same process. Every thread has its own memory cache. Many threads run within a single process. This reduces consumption of resources.  If a thread reads shared data it stores this data in its own memory cache.

By definition, multitasking is when multiple processes sharing  common processing resources such as a CPU time. Multi-threading extends the idea of multitasking into applications where you can subdivide specific operations within a single application into individual threads. Each of the threads  run in parallel. Multi-threading enables you to write in a way where multiple activities can proceed concurrently in the same program.

The idea of a thread is that of a lightweight unit of execution—smaller than a process, but still capable of executing arbitrary Java code. The usual way that this is implemented is for each thread to be a fully fledged unit of execution to the operating system but to belong to a process, with the address space of the process being shared between all threads comprising that process. This means that each thread can be scheduled independently and has its own stack and program counter but shares memory and objects with other threads in the same process.

Life Cycle Of a Thread

A thread goes through various stages in its life cycle. For example, a thread is born, started, runs, and then dies. The following diagram shows the complete life cycle of a thread.

Following are the stages of the life cycle −

  • New− A new thread begins its life cycle in the new state. The thread has been created (its constructor has been called).It remains in this state until the program starts the thread.
  • Runnable– The thread’s start() method has been called,the thread becomes Runnable. The thread is available to be run(execute code) by the thread scheduler.
  • Waiting– The thread has been temporarily removed from the RunnableA thread transitions back to the Runnable state only when another thread signals the waiting thread to continue executing.
  • Timed Waiting(also known as Blocked)− A runnable thread can enter the timed waiting state for a specified interval of time. This is achieved by calling sleep() method. This method can take argument in terms of time interval. A thread in this state transitions back to the runnable state when that time interval expires or when the event it is waiting for occurs. An event like completion of I/O
  • Terminated (Dead)− A runnable thread enters the terminated state when it finishes execution of run() method.  It remains there until the application ends.


Diagram below depicts various state of a thread and shows method  which will transform a thread from one state to another state. Here Ready state is also called as Runnable state .

   The diagram represents all the phases of life cycle of a thread. 


Figure 1. Life cycle representing all phases of a thread.

Multithreading environment in java can be implemented in two ways as the diagram below shows.

  1. Create a class(user defined) which extends java built-in Thread class.
  2. Create a class (user defined) which implements java built-in Runnable interface.

Classes and interfaces to create threads


Thread (Class): A class that creates and defines thread. This class inherits the Object class and implements Runnable interface.

Runnable(interface): The only method in this interface is the run() method.

Object: wait(), notify() and  notifyAll() are methods of this class used for threading.

Example of single thread running by creating a class which extends Thread class.


class SinglethreadDemo extends Thread

{                                   // method of Runnable interface

public void run() {

System.out.println (” My single thread is in running state”); }


public static void main (String args[]) {

SinglethreadDemo obj = new SinglethreadDemo ();

obj.start();                             // Calling start() method of Thread class




For further information call : Vissicomp Technology    26708190/9320957718


Written and Edited By                                                                 Vissicomp Technology

Dr. Ashwin I Mehta


Posted on Updated on


Raspberry Pi is a credit-card sized computer manufactured and designed in the United Kingdom by the Raspberry Pi foundation with the intention of teaching basic computer science to school students and every other person interested in computer hardware, programming and DIY-Do-it Yourself projects.

The Raspberry Pi is manufactured in three board configurations through licensed manufacturing deals with Newark element14 (Premier Farnell), RS Components and Egoman. These companies sell the Raspberry Pi online. Egoman produces a version for distribution solely in China and Taiwan, which can be distinguished from other Pi by their red coloring and lack of FCC/CE marks.

The hardware is the same across all manufacturers. The Raspberry Pi has a Broadcom BCM2835 system on a chip (SoC), which includes an ARM1176JZF-S 700 MHz processor, VideoCore IV GPU and was originally shipped with 256 megabytes of RAM, later upgraded (Model B & Model B+) to 512 MB. It does not include a built-in hard disk or solid-state drive, but it uses an SD card for booting and persistent storage, with the Model B+ using a MicroSD.

The Foundation provides Debian (Type of linux distro) and Arch Linux ARM distributions for download. Tools are available for Python as the main programming language, with support for BBC BASIC (via the RISC OS image or the Brandy Basic clone for Linux), C, Java and Perl.

Before you plug anything into your Raspberry Pi, make sure that you have all the equipment you need:

  • A monitor with the correct cable and adapter
  • A micro USB power supply
  • A wired keyboard and mouse, or a wireless keyboard and mouse with a Bluetooth adapter
  • A micro SD card
  • A Raspberry Pi


To get started with Raspberry Pi, you also need an operating system.

Plugging in your Raspberry Pi

  1. Begin by placing your SD card into the SD card slot on the Raspberry Pi. It will only fit one way.
  2. Next, plug your keyboard and mouse into the USB ports on the Raspberry Pi.
  3. Make sure that your monitor or TV is turned on, and that you have selected the right input (e.g. HDMI 1, DVI, etc).
  4. Connect your HDMI cable from your Raspberry Pi to your monitor or TV.
  5. If you intend to connect your Raspberry Pi to the internet, plug an Ethernet cable into the Ethernet port, or connect a WiFi dongle to one of the USB ports (unless you have a Raspberry Pi 3).
  6. When you’re happy that you have plugged all the cables and SD card in correctly, connect the micro USB power supply. This action will turn on and boot your Raspberry Pi.

Raspberry Pi networking

You’ll probably want to connect your Raspberry Pi to your local network or the internet. You can use any of the following options to do this:

Connecting via Ethernet

The Raspberry Pi has an Ethernet port, alongside the USB ports. If your Raspberry Pi is situated close to a router, access point, or switch, you can connect to a network using an Ethernet cable.


Once you’ve plugged the Ethernet cable into the Raspberry Pi and the other end into an access point, your Raspberry Pi will automatically connect to the network.

Connecting via WiFi

If you have a Raspberry Pi 3, then there is built-in WiFi. If you’re using an earlier version of the Raspberry Pi, then you’ll need a USB WiFi dongle.

Some WiFi dongles, when used with the Raspberry Pi, are simple plug and play devices. Others require specific drivers, and may not be compatible


with the Raspberry Pi. Make sure you read the device manufacturer’s documentation before making a purchase.

You can buy the official Raspberry Pi WiFi dongle from The Pi Hut or Farnell.

Steps Of OS Installation:

1.Download Wheezy from Raspberry pi & extract it in new folder while extracting it you will get an image file with dot img extension.

2.Download SD card For matter from source forge net on your local Desktop

3.Format your SD card by inserting in Card reader and connect it to your desktop.

4 Make SD card  bootable By using SD card For matter

4.Now insert SD card in raspberry pi

5.Download windows 32 disc imager to write the OS

6.Open windows 32 disc imager.

7.There is “browse” Option on imager. Browse  dot img file and click on “ write “ button and exit. Os will successfully install on SD card

8.Connect all hardware accessories to your Raspberry pi kit

9.Turn on the  Raspberry pi kit ,tons of code will run on your desktop.

It will ask you for id and password your default id is pi and password is raspberry you will get special Raspberry pi window on desktop

For further information keep reading our blog. OR call Vissicomp

Written By                                                                     Edited By

Mrs. Jyoti Khandagale                                                 Dr. Ashwin Mehta