Tuesday, March 31, 2009

Concurrency anti-patterns in JW Blogs

JAVAWORLD'S ENTERPRISE JAVA ALERT
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

Whitepaper: The Hybrid Approach to Security

JupiterwebSpecial Offers
Featured Technical Whitepapers and Resources
Whitepaper: The Hybrid Approach to Security
Sponsored by Trend Micro
Trend Micro's Smart Protection Network is based on a hybrid approach that Trend calls "Cloud-Client Architecture," it integrates hosted security (or cloud-based) services, gateways, and software. Reduce endpoint resource consumption, network bandwidth consumption, malware, and overall risk with Trend Micro.
>>Learn more!
PDF: Video Conferencing--Fact vs. Myth
Sponsored by Polycom
Video conferencing isn't just for large corporations with deep pockets. Don't let antiquated myths stop you from realizing the very real benefit of video conferencing in your organization.
>>Download your copy now!
More Technical Whitepapers and Resources from Internet.com

 Whitepaper: Next-Generation Technology for Virtual I /O and Blade Servers
Sponsored by HP
HP Virtual Connect and HP Virtual Connect Enterprise Manager virtualize I/O connections to SAN and LAN environments, enabling organizations to wire once and add or replace servers or change datacenter connections on the fly. >>
 Whitepaper: Build the Perfect BladeSystem
Sponsored by HP
The biggest difference between blade architectures and those based on traditional servers is the infrastructure and how it's built. Most HP BladeSystem components are nearly identical to the server, storage, and network components you are most familiar with today. Learn why the HP BladeSystem is a smarter way to build an infrastructure. >>
 Database Security Whitepaper: Preventing Enterprise Data Leaks at the Source
Sponsored by Oracle
Information protection and control (IPC) requires enterprises to start by securing data at the source - their databases. This IDC white paper presents the benefits of a preemptive approach to IPC, and highlights the Oracle database helps enterprises protect themselves from costly data breaches. >>
 Whitepaper: ITIL Version 3 - What It Means and How IBM Can Help
Sponsored by IBM
For a growing business, its increasingly difficult to integrate technological solutions and services to improve service management. So various frameworks have been created to help today's IT professionals optimize their use of technology in managing IT processes. The third version of the Information Technology Infrastructure Library (ITIL) provides the latest set of process best practices for any service management improvement effort. Read on to find out how IBM can help customers implement these best practices from ITIL. >>
 eBook: How to Build a Storage Strategy for Your SMB
Sponsored by HP
Many storage solutions are aimed at large enterprises and are designed to address their concerns surrounding information lifecycle management and corporate compliance. But small and medium-sized businesses have storage concerns of their own. Download this eBook now to learn how to choose a storage server and more. >>
 Whitepaper: Make Business Relevant Information Instantly Available to More Users
Sponsored by SAP
Business Intelligence is taking on an expanded role within organizations, but several factors need to be addressed in order to equip the users for success. This paper examines how SAP BusinessObjects Polestar combines the speed and simplicity of search with the trust and analytical power of business intelligence to deliver immediate answers to business questions. Download now! >>
Internet.com is a WebMediaBrands Inc. property
23 Old Kings Highway South
Darien, CT 06820
You are receiving this email because you have registered for a tutorial, download, whitepaper, webcast, or have elected to receive information or offers from Internet.com. If you wish to be removed from future Internet.com Tech Alerts, please go to: http://e-newsletters.internet.com/juptech_unsub.html

New IT Director's Guide to Reducing Costs in the Datacenter

Find out how to reduce costs in your datacenter with this new IT Director's Guide. Download the white paper.

Find out how to reduce costs in your datacenter Stay Ahead of Ever-Increasing Datacenter Demands
Slash costs and improve performance with Sun servers
Dear Athens Suthakar,

Faced with keeping your datacenter agile and running smoothly — even under the financial constraints of tough economic times? Then this new white paper, An IT Director's Guide to Reducing Costs Through Better Server Utilization, is a must read.

By consolidating enterprise applications onto the latest Sun SPARC Enterprise servers and taking advantage of virtualization technology, you can optimize your datacenter efficiency and performance while cutting costs.

In this white paper, you'll learn:


»  How Sun servers use less energy and occupy less space than competing servers — all while meeting or exceeding performance levels
»  How Sun saved millions of dollars by consolidating datacenter operations and replacing older systems with the latest Sun technology
»  How Sun customers are slashing costs by refreshing their aging server infrastructure with Sun SPARC Enterprise systems

Get the details in this indispensable white paper.

 Download the White Paper

Questions? Contact us.

Thank you,

Sun Microsystems, Inc.
Download the white paper: An IT Director's Guide to Reducing Costs Through Better Server Utilization
Sun Microsystems, Inc. respects your privacy. You are receiving this email at athenssuthakar.javaupdates@blogger.com because you elected to receive general communications from Sun Microsystems, Inc.
Privacy Policy   |   Trademarks  |   Manage Subscriptions  |   Update My Profile  |   Unsubscribe
Please do not reply to this email. Instead, contact the editor.
Sun Microsystems, Inc., 18 Network Circle, M/S: UMPK18-124, Attn: Global eMarketing, Menlo Park, CA 94025 USA
© 2009 Sun Microsystems, Inc. All rights reserved.