Solutions for Java developers
03/31/09
By Obi Ezechukwu
We know from E.G. Coffman's 1971 article that there must be four
conditions for a deadlock to occur:
1. Mutual exclusion:The concurrent threads of execution must share
state which cannot be accessed by more than one thread (or class
of threads) at any given point in time.
2. Resource hold and wait:Processes are not prevented from
requesting new resources regardless of whether or not they are
already holding other resources.
3. No Preemption:A processes may not be forcibly deprived of the
resources which it currently holds.
4. A circular wait condition:This is the final and most
identifiable condition required for a deadlock. It occurs when
one or more resources form an interdependent and circular chain,
such that each process Tiin the chain waits for a resource that
is already held by the next process Txin the chain, and
Txequally requires (directly or indirectly) the resource held by
Ti.
Thus, preventing deadlock can be as simple as ensuring that all
of the above four conditions never hold at the same time.
Unfortunately life is not that simple. In reality, the first
three conditions are actually quite useful for a variety of
reasons which most concurrent application developers are fully
aware off. For this reason, deadlock prevention often centres on
preventing the final condition taking root.
In the following series of posts, I will explore three
concurrency anti-patterns that can lead to circular wait
conditions. In addition to describing the anti-patterns, I will
also show code samples to illustrate each one, and discuss
solutions and workarounds to counteract them. The first
anti-pattern is called "No Arbitration." For an amusing take on
the anti-pattern's deadlock-making functional requirements,
examine this piece of legislation passed in the Midwestern US
State of Kansas: "When two trains approach each other at a
crossing, both shall come to a full stop and neither shall start
up again until the other has gone..."
Read more: Deadlock-inducing anti-pattern # 1: No Arbitration
http://www.javaworld.com/community/node/2701
1. Java concurrency with thread gates
http://www.networkworld.com/nljavaworldsente185460
2. Understanding actor concurrency, Part 2: Actors on the JVM
http://www.networkworld.com/nljavaworldsente188943
3. Avoid synchronization deadlocks
http://www.networkworld.com/nljavaworldsente189565
By Louis Iacona
Applying a one-time password (OTP) scheme between distributed
systems makes it more difficult for a would-be intruder to
access and gain unauthorized control of restricted resources
such as data, physical devices, or service end points. An OTP
scheme is obviously a step up from completely open access, or
access limited only by physical network barriers. But a solution
based on an OTP challenge also has some advantages over static,
infrequently changing passwords, because the window of
opportunity to gain access to credentials is much smaller.
There's a practical place for either type of authentication, or
even both used in concert.
The Lamport OTP approach is based on a mathematical algorithm
for generating a sequence of "passkey" values, each successor
value based on the value of its predecessor. This article
presents a simple service that is made more secure by adopting
the Lamport OTP scheme. I'll demonstrate the concept and
mechanics of this approach through a series of client/service
interactions. I'll also present a Java-implemented framework
that the existing client/service components can easily leverage.
Read more: The mechanics of Lamport OTP
http://www.networkworld.com/nljavaworldsente189566
VonQ says: I'm trying to wrap my mind around why all my beginner
java books use the main method to instantiate objects of a
different class than the one it is being instantiated in, such
as the one below. I've tested it and know it works but why don't
I ever see it in the books? Is there a drawback to creating a
new object of the same object that you are in?
6 Replies:
-KKelly: You can obviously instantiate the class using either
form. However, when you instantiate the class from within the
main method of the same class, you're creating a little more
complexity than you'd probably like to have in a textbook trying
to explain how things work ...
-Garyo: Your question is actually quite good. Everyone has
thought the same thing at some point. No recreation of objects
is occurring. That is the program structure in Java. You can
break it up though (2 programs in the same directory) ...
Read more and reply in this thread: Instantiating object main
method http://www.javaworld.com/community/node/2657 1. Esther Schindler: Is software automation a career threat?
http://www.javaworld.com/community/node/2699
2. Dustin Marx: GPS systems and IDEs: Helpful or harmful?
http://www.javaworld.com/community/node/2712
3. Johannes Brodwall: Planning by value
http://www.javaworld.com/community/node/2698
You've hit the tip of the iceberg: Read more in JW Blogs
http://www.javaworld.com/community/
_______________________________________________________________
This newsletter is sponsored by Dell
Realities of Planning a Vista Migration
This webcast details the key elements and best practices
essential to planning a successful large-scale migration to
Windows Vista so you can immediately begin to reap the benefits
of improved security, lower operating costs and more productive
mobile computing.
http://adserver.fattail.com/redir/redirect.asp?CID=293527
_______________________________________________________________
What you need to see all 7 layers
Get all the tools you need to see all 7 layers of your network. Fluke's OptiView Analyzer combines protocol analysis, active discovery, and device and traffic analysis in a mobile solution, giving you the information you need to control your network and minimize disruption. http://www.nww.com/rpgx.jsp?c=XU1PTA7013Z4155
Click here for your free trial.
_______________________________________________________________
This Newsletter Subscription Compliments of: Linuxworld.com http://www.linuxworld.com
ALSO FEATURED ON JAVAWORLD
Understanding actor concurrency, Part 2: Actors on the JVM
http://www.networkworld.com/nljavaworldsente188943
Erlang isn't the only language for implementing actor
concurrency. Find out how actors work and see them implemented
in Scala's standard library, Groovy's GParallelizer, and the
Java libraries Kilim, ActorFoundry, Actors Guild, and Jetlang
Open source Java projects: Jakarta Cactus
http://www.networkworld.com/nljavaworldsente188428
Unit-testing server-side code is famously challenging, but
Jakarta Cactus does make it easier. Learn how Cactus extends
JUnit with an in-container strategy that lets you execute test
cases for servlets, EJBs, and other server-side code. You'll
also learn how to automate your Cactus-based tests.
Writing good unit tests, Part 1: Follow your GUTs
http://www.networkworld.com/nljavaworldsente187286
What do you know about the quality of your unit tests? Probably
not as much as you know about your production code. Klaus Berg
explains why craft matters just as much for test code as for
production code, then provides a comprehensive listing of agile
tools and best practices for improving the quality of your unit
tests.
ActionScript for Java developers, Part 2
http://www.networkworld.com/nljavaworldsente186633
Like other dynamic languages, ActionScript has capabilities and
usage patterns that could take a Java developer by surprise. In
this second half of his guide to the differences between Java
and ActionScript 3, Chet Haase discusses properties, dynamic
behavior, and functions.
_______________________________________________________________
This newsletter is sponsored by Dell
Realities of Planning a Vista Migration
This webcast details the key elements and best practices
essential to planning a successful large-scale migration to
Windows Vista so you can immediately begin to reap the benefits
of improved security, lower operating costs and more productive
mobile computing.
http://adserver.fattail.com/redir/redirect.asp?CID=293527
_______________________________________________________________
UPCOMING ON JAVAWORLD
-REST for Java developers, Part 4: The future is RESTful
-Writing good unit tests, Part 2
-Jump into JavaFX, Part 4: Advanced APIs
-Cloud-ready, multicore-friendly code, Part 2
-Introduction to Spring MVC
Podcasts:
-Alex Miller: Talkin' about Terracotta
-Make way for Jetty: Coming of age at 12
JavaWorld's Daily Brew - Starting conversations in the Java
developer community
http://www.javaworld.com/community
_______________________________________________________________
BONUS FEATURE
Network World's IT Resource Library. Whether you're looking to gear
up on one specific topic or you're trying to stay current on
several areas, Network World's resource library has what you're
looking for. Our comprehensive collection of resources will make
your job easier. Visit Now
http://www.nww.com/rpgx.jsp?c=XU1PTAZ3783
_______________________________________________________________
May we send you a free print subscription to Network World?
You've got the technology snapshot of your choice delivered at
your fingertips each day. Now, extend your knowledge by
receiving 50 FREE issues to our print publication. Apply today
at http://www.subscribenw.com/nl2
International subscribers click here:
http://nww1.com/go/circ_promo.html
_______________________________________________________________
SUBSCRIPTION SERVICES
To make newsletter subscription changes or cancellation, please
go to:
http://www.subscribenw.com/nl/login.jsp
To change your e-mail address, go to:
http://www.subscribenw.com/nl/eclogin.jsp
Subscription questions? Contact Customer Service by replying to
this message.
This message was sent to: athenssuthakar.javaupdates@blogger.com
Please use this address when modifying your subscription.
_______________________________________________________________
For advertising information, write Susan Cardoza, Associate
Publisher Online, at: mailto:sponsorships@nwfusion.com
_______________________________________________________________
JavaWorld is a trademark or registered trademark of Sun
Microsystems, Inc. in the United States and other countries, and
is used under license by International Data Group, Inc. All
other product names and trademarks used are the trademarks of
their respective owners.
Copyright 2009 JavaWorld.
http://www.javaworld.com



