CORE API / CATATAN</>↗Core API14 Agt 2011
This example describe how to get the number of active threads in this thread group. The result might not reflect concurrent activity, and might be affected by the presence of certain system threads. Due to the inherently imprecise nature of the result, it is recommended that this method only be used for informational purposes. package […]
CORE API / CATATAN</>↗Core API14 Agt 2011
In this example you’ll see how to obtain the number of active thread in the current thread. You can use the Thread.activeCount() method to get this information. package org.kodejava.lang; public class CountActiveThread { public static void main(String[] args) { Thread t = new Thread(() -> System.out.println("Hello…")); t.start(); // Get the number of active threads in […]
CORE API / CATATAN</>↗Core API14 Agt 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 / CATATAN</>↗Core API14 Agt 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 / CATATAN</>↗Core API14 Agt 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 / CATATAN</>↗2D API13 Agt 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 […]