News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Developer.com:
Threads Versus The Singleton Pattern
June 01, 2007 @ 10:43:00

In a new tutorial on the Developer.com website today, they explore the difference between (and the benefits and disadvantages of) the singleton pattern versus threading in a PHP application.

Although you probably could address some [of these] issues with the judicious use of synchronized blocks, do not overlook the utility of the ThreadLocal class. In this article, I will demonstrate the risk of not accounting for Threads when using a singleton pattern and show how simple it is to address.

They start with the creation of a ThreadLocal class, one that allows the developer to communicate with the threads, and its usage. In contrast, they also create the Singleton class, showing the creation method of multiple objects of the same type.

They do, however, point out an issue that the threaded method has - unreliable results. Help is on the horizon, though, in the form of a HelperFactory class to manage the connections a bit more efficiently.

0 comments voice your opinion now!
thread singleton designpattern tutorial thread singleton designpattern tutorial


blog comments powered by Disqus

Similar Posts

PHPro.org: Read Line From File (stream_get_line)

PHPMaster.com: From Zero to Cloud: Setting up an EC2 Sandbox, Part 3

Lorna Mitchell's Blog: Building A RESTful PHP Server: Routing the Request

Chris Shiflett's Blog: OSCON 2006 Redux

Kevin Schroeder's Blog: Connecting to the Zend Developer Cloud using NetBeans for PHP


Community Events

Don't see your event here?
Let us know!


framework wordpress extension laravel5 podcast api opinion laravel introduction unittest series development community language interview conference middleware release voicesoftheelephpant library

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework