CORE API / NOTES</>↗Core API07 Nov 2010
A thread is alive or running if it has been started and has not yet died. To check whether a thread is alive use the isAlive() method of Thread class. It will return true if this thread is alive, otherwise return false. package org.kodejava.lang; public class ThreadAliveDemo implements Runnable { public static void main(String[] args) […]
CORE API / NOTES</>↗Core API06 Nov 2010
You can test if a thread is a daemon thread or a user thread by calling the isDaemon() method of the Thread class. If it returns true then the thread is a daemon thread, otherwise it is a user thread. package org.kodejava.lang; public class ThreadCheckDaemon implements Runnable { public static void main(String[] args) { Thread […]
CORE API / NOTES</>↗Core API06 Nov 2010
A daemon thread is simply a background thread that is subordinate to the thread that creates it, so when the thread that created the daemon thread ends, the daemon thread dies with it. A thread that is not a daemon thread is called a user thread. To create a daemon thread, call setDaemon() method with […]
CORE API / NOTES</>↗Core API05 Nov 2010
Here is another example that use the Thread.sleep() method. In the example we create two instances of the ThreadSleepAnotherDemo, we give each thread a name and the sleep interval so that we can see how to thread execution. package org.kodejava.lang; import java.util.Calendar; public class ThreadSleep implements Runnable { private final String threadName; private final long […]
REGEX / NOTES</>↗Regex05 Nov 2010
Capturing groups are numbered by counting the opening parentheses from left to right. To find out how many groups are present in the expression, call the groupCount() method on a matcher object. The groupCount() method returns an int showing the number of capturing groups present in the matcher’s pattern. package org.kodejava.example.regex; import java.util.regex.Matcher; import java.util.regex.Pattern; […]
REGEX / NOTES</>↗Regex05 Nov 2010
This example show you how to attach quantifier to character classes or capturing group in regular expressions. package org.kodejava.example.regex; import java.util.regex.Pattern; import java.util.regex.Matcher; public class CombineWithQuantifier { public static void main(String[] args) { // [abc]{3} –> apply quantifier in character class. // Find 'a' or 'b' or 'c', three times in a row. // // […]