2 Minutes To Code (β Version)

Debugging with Eclipse - 2 minute tutorial

Source code of Workshop.java class

Given below is the source code of Workshop.java class which is used in the debug example of this tutorial.
package com.techfundaes.workshopBag;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

public class Workshop implements Runnable
{
	
	long localCarsCount = 0;
	int batchSize = 5;
	long sleepInterval = 500;
	Thread thread = null;
	int sequenceNumber = 0;
	List<Car> paintedCarsList = new ArrayList<Car>();
	
	public void run()
	{
		while(true)
		{
			paintCars();
		}
	}

	public void paintCars()
	{
		for(int i = 0; i < batchSize; i++)
		{
			Car car = new Car(Calendar.getInstance().getTime(), thread.getName());
			paintedCarsList.add(car);
			localCarsCount += 1;
		}	
		try { Thread.sleep(sleepInterval);}catch(Exception e){e.printStackTrace();}
	}
	
	public long getLocalCarsCount()
	{
		return localCarsCount;
	}
	
	public String stopPaintingCars()
	{
		sleepInterval = 100000000000000l;
		return "Stopped Painting Cars";
	}
	
	public String startPaintingCars()
	{
		sleepInterval = 1000;
		thread.interrupt();
		return "Started Painting Cars";
	}
	
	public int getBatchSize()
	{
		return batchSize;
	}
	
	public String setBatchSize(int batchSize)
	{
		this.batchSize = batchSize;
		return "batch size set to "+ batchSize + ".";
	}
	
	public String setBatchSizeAndSleepTime(int batchSize, long sleepInterval)
	{
		this.batchSize = batchSize;
		this.sleepInterval = sleepInterval;
		return "batch size set to "+ batchSize + ", sleepInterval to "+sleepInterval +" ms";
	}
}