Apparently you can also use the Collections.synchronizedMap() method to
synchronize HashMap at creation time:

http://java.sun.com/javase/6/docs/api/java/util/HashMap.html





joseph wamicha wrote:
> 
> It takes care of threads trying to access the same resource. The method is
> synchronized and all locks and mutexes are taken care of by the JAVA
> runtime. Much more convenient than doing threading and resource management
> in C.
> 
> On 3/13/07, Dan Rossi <[EMAIL PROTECTED]> wrote:
>>
>> ive seen the statement before way over my head though
>>
>> http://today.java.net/pub/a/today/2004/08/02/sync1.html
>>
>>
>> joseph wamicha wrote:
>> > You may try using JAVA "synchronized" methods.
>> >
>> > On 3/13/07, Dan Rossi <[EMAIL PROTECTED]> wrote:
>> >>
>> >> Im also interested aswell, im also filling a hashmap with values to
>> >> fudge the FMS virtual directories feature, but applied in the
>> >> filenamegenerator bean for now. Im wondering what the most safe and
>> >> efficient way to add these values are ?
>> >>
>> >> public void setVirtualDirectories(String virtualDirectories) {
>> >> vdirectories = new HashMap<String,String>();
>> >> directories = virtualDirectories.split(",");
>> >> for (int i = 0; i < directories.length; i++) {
>> >> directories[i] = directories[i].trim();
>> >> String[] paths = directories[i].split(";");
>> >>
>> >> if (!paths[0].equals("") && !paths[1].equals(""))
>> >> {
>> >> vdirectories.put(paths[0], paths[1]);
>> >> }
>> >> }
>> >> }
>> >>
>> >> public String generateFilename(IScope scope, String name,
>> >> String extension, GenerationType type) {
>> >> String filename;
>> >>
>> >> filename = playbackPath + name;
>> >>
>> >> String[] paths = name.split("/");
>> >>
>> >>
>> >> if ((vdirectories.size() > 0) && vdirectories.containsKey(paths[0]))
>> >> {
>> >> filename = vdirectories.get(paths[0]) + paths[1];
>> >> }
>> >>
>> >> log.info("Generated FilePath: " + filename);
>> >> return filename;
>> >>
>> >> }
>> >>
>> >> the first path is split from the filename.
>> >>
>> >> properties setting
>> >>
>> >> virtualDirectories=dir1;file:C:/somedir, dir2;file:D:/somedir
>> >>
>> >>
>> >> Sam Bou wrote:
>> >> > Is Red5 single or multi-threaded?  I noticed that in
>> >> http://mirror1.cvsdude.com/trac/osflash/red5/changeset/1732 that the
>> >> default is multi-threaded but I'm not sure if that is only for the IO
>> >> processes or for other processes as well.
>> >> >
>> >> > If it's multi-threaded, as a Java newbie I'm wondering if I need to
>> >> synchronize the appConnect and other methods if I have something like
>> >> the
>> >> following, where many connections will be accessing the same variables
>> >> clientCount and clientsMap:
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > public class Application extends ApplicationAdapter {
>> >> >
>> >> >     private int clientCount = 0;
>> >> >
>> >> >     private Map<String, List<String>> clientsMap = new
>> HashMap<String,
>> >> List<String>>();
>> >> >
>> >> >     public boolean appConnect(IConnection conn, Object[] params) {
>> >> >
>> >> >              clientCount++;
>> >> >
>> >> >             clientsMap.put(clientId, clientInfoList);
>> >> >     }
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > Any advice appreciated.
>> >> >
>> >> > Sam
>> >>
>> >
>> >
>> ------------------------------------------------------------------------
>> >
>> > _______________________________________________
>> > Red5 mailing list
>> > [email protected]
>> > http://osflash.org/mailman/listinfo/red5_osflash.org
>> >
>>
>>
>> _______________________________________________
>> Red5 mailing list
>> [email protected]
>> http://osflash.org/mailman/listinfo/red5_osflash.org
>>
> 
> 
> 
> -- 
> C is forever.
> 
> _______________________________________________
> Red5 mailing list
> [email protected]
> http://osflash.org/mailman/listinfo/red5_osflash.org
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Single-or-Multi-Threaded--tf3395583.html#a9462443
Sent from the Red5 - English mailing list archive at Nabble.com.


_______________________________________________
Red5 mailing list
[email protected]
http://osflash.org/mailman/listinfo/red5_osflash.org

Reply via email to