A simple application for printing file contents as hexadecimal.
Fixing Common Pitfalls of Codemods
2 days ago
Miscellaneous Computer Code
using System; public class HelloWorld { public static void Main(String[] args) { Console.WriteLine("Hello, World!"); } }
${example.expression.language.expression}
EDIT 2009/05/28: It has been pointed out to me that a far easier way to do all this is using this method:
URL url = Location.class.getProtectionDomain()
|
...which makes everything below here pointless. You live and learn!
Java
programmer, you will be familiar with synchronized
blocks.
Object myObject = //some instance synchronized(myObject) { //do some thread-sensitive //work on myObject }Sometimes, you want to synchronize on a transient object - a resource that isn't going to stay in memory.
HttpServletSession
instance can't be recreated as a facade object every time it is requested. That makes the session instance a poor candidate for a synchronized
lock. There is nothing in the specification that prevents the container implementer from always serializing session attributes as soon as they are set either. That makes session attributes poor candidates for synchronization
locks. Note: existing implementations may support either of these approaches in practice, but lets say our imaginary servlet container doesn't. However, the session ID will be consistent across requests.
public class HelloWorld {
|