Det har vært mange diskusjoner rundt politikernes ønske om å innføre nettbrett, eller mer konkret, innføring av iPad som en del av lokalpolitikernes hverdag. Hovedbegrunnelsen var da at man ønsket å finne metoder som hjalp til med å kutte ned på utgifter. Det gikk jo en god del utgifter årlig bare på utskrifter og slikt. Read more about Nettbrett, ett rett brett?[…]
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. The example above print the following example output: Could this be done easier? Let me know!
Use the getThreadGroup() method of Thread class to get the thread group to which the thread belongs. Could this be done easier? Let me know!
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. Could this be done easier? Let me know!
Starting from Java 7 release you can now use a string in the switch statement. On the previous version we can only use number or enum in the switch statement. The code below give you a simple example on it. Do you know better ways to do this?
The multi-catch is a language enhancement feature introduces in the Java 7. This allow us to use a single catch block to handle multiple exceptions. Each exception is separated by the pipe symbol (|). Using the multi-catch simplify our exception handling and also reduce code duplicates in the catch block. Let’s see an example below: Read more about Use multi-catch statement[…]
The java.nio.file.Files.readAllLines() method read all lines from a file. This method ensures that the file is closed when all bytes have been read or an I/O error, or other runtime exception, is thrown. Bytes from the file are decoded into characters using the specified charset. Note that this method is intended for simple cases where Read more about Read all lines from a file[…]
The try-with-resources statement is introduced in the Java 7. With this new statement we can simplify resource management in our program, it also known as ARM (Automatic Resource Management). This statement is a try statement that declares one or more resources. After the program finish with the resource it must be closed. The try-with-resources ensures Read more about Use try-with-resources statement[…]
One thing that we need to do manually when programming using JDBC is to make sure to close all the resources that we use. All resources including the ResultSet, Statement and Connection must be closed. This usually will produce a lot of boiler plate code in our program. Starting from JDBC 4.1 which is a Read more about How to automatically close resources in JDBC[…]
You can destroy a thread group by using destroy() method of ThreadGroup class. It will cleans up the thread group and removes it from the thread group hierarchy. It’s not only destroy the thread group, but also all its subgroups. The destroy() method is of limited use: it can only be called if there are Read more about Destroy a thread group[…]