CORE API / NOTES</>↗Core API14 Aug 2011
Use method activeGroupCount() of ThreadGroup class to get estimate number of active groups in the thread group and use activeCount() to get estimate number of active threads in a thread group. package org.kodejava.lang; public class ActiveGroupCount { public static void main(String[] args) { ThreadGroup root = new ThreadGroup("RootGroup"); ThreadGroup server = new ThreadGroup(root, "ServerGroup"); ThreadGroup […]
CORE API / NOTES</>↗Core API14 Aug 2011
Use the getThreadGroup() method of Thread class to get the thread group to which the thread belongs. package org.kodejava.lang; public class GetThreadGroup { public static void main(String[] args) { // Create thread groups ThreadGroup group = new ThreadGroup("ThreadGroup"); ThreadGroup anotherGroup = new ThreadGroup(group, "AnotherGroup"); // Create threads and placed into thread group Thread t1 = […]
CORE API / NOTES</>↗Core API14 Aug 2011
To get the state of a thread use getState() method of a Thread class. One thing to be noted is that this method is designed for use in monitoring of the system state, not for synchronization control. package org.kodejava.lang; public class GetThreadState implements Runnable { public static void main(String[] args) { Thread thread = new […]
2D API / NOTES</>↗2D API13 Aug 2011
This program read a file of data and draw a graph of the data points in the file. The graph is drawn in a window with three sections. The first section contains three buttons that initiate the program’s actions. Actions can also be initiated via control keys. The second section displays the data to be […]
APACHE COMMONS / NOTES</>↗Apache Commons10 Aug 2011
This example demonstrates how to use the BasicDataSource class of Apache Commons DBCP to create a basic requirements for database connection. The configuration of the data source can be defined using some property method provided by this class. The basic properties are the driver classname, connection url, username and password. After the datasource ready we […]
APACHE COMMONS / NOTES</>↗Apache Commons10 Aug 2011
This example shows you how to create a connection pool implementation using the Apache Commons DBCP library. package org.kodejava.commons.dbcp; import org.apache.commons.dbcp2.*; import org.apache.commons.pool2.impl.GenericObjectPool; import org.apache.commons.pool2.impl.GenericObjectPoolConfig; import javax.sql.DataSource; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; public class ConnectionPoolExample { private static final String...