|
| |||||||||
| Tags: java, multithreading, programming language, safe, thread |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Thread- Safe Classes
Hello, Does someone could tell me a place where you can find a list more or less complete collections of Java classes that are thread-safe and which are not? Thank you in advance. I am new to this concept and do not want to take any risk, so please any help in this will be highly appreciated. |
|
#2
| |||
| |||
| Re: Thread- Safe Classes
Hello, Here are few points on this - The classes of the old APIs are thread-safe (Hashtable, Vector and Stack) But should not be used in general. - Unless I am mistaken, the classes of the "new" Collections API (all other collections java.util) Are not thread-safe, but it is possible to obtain a thread-safe version via methods Collections.synchronizedXXXX (). - Finally collections package java.util.concurrent are logical thread-safe. |
|
#3
| |||
| |||
| Re: Thread- Safe Classes
Hello, Even I am trying a similar kind of a code, but I can not get the logic. It means that the only data structures that can be used without the sync itself is the object returned by Collections synchronizedXXX () and objects in java.util.concurrent, according to the practice whereby all application must be considered as a multithreaded application? I am not conferable with this. |
|
#4
| |||
| |||
| Re: Thread- Safe Classes
Hello, Not exactly, your application is heavily threaded all data will be handled by multiple threads challenge. Thus, it has now to determine the data / process need to be thread safe. I do not think this will make you any problem. So, you can carry on with this code and I think this is safe for you program and if you think this is not safe then you can use the multithreading in which is provided by java. Last edited by Linux-Us : 09-02-2010 at 11:45 PM. |
|
#5
| |||
| |||
| Re: Thread- Safe Classes
Hello, I can integrate this conversation by asking a small question. In the case where a collection should be synchronized, which solution to choose? 1 / Vector and etc. 2 / Standard collection (LinkedList and other) synchronized by us. 3 / classes package java.util.concurrent Thanks in advance for your reply. |
|
#6
| |||
| |||
| Re: Thread- Safe Classes
Hello, Vector, Stack and Hashtable you can forget them. these classes should be used. If necessary collections thread-safe, it generally uses synchronized versions of standard collections (retrieved via methods synchronisedXXX () class Collection) The collections available in this package java.util.concurrent used primarily for specific needs: - The BlockingQueue is a queue (a queue thus FIFO) which hangs when trying to add or remove an element as the space available is not sufficient (model producer / consumer). - The ConcurrentMap Map is a thread-safe which is distinguished by the fact that it can be supervised by several bolts of exclusion, ie it can allow multiple simultaneous entries, unlike the conventional synchronized Map n ' only one exclusion lock (only 1 write simultaneously possible as a result). |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Thread- Safe Classes" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Synchronize a producer thread and a consumer thread in C# | Ayuka | Software Development | 6 | 10-11-2010 04:04 AM |
| IE9 Beta and Norton Safe Web and Identity Safe | Phillips | Networking & Security | 6 | 24-09-2010 07:19 AM |
| Safe Eyes Mobile - The First Kid-Safe Browser for Apple iPhone | monsitj | Portable Devices | 2 | 07-02-2009 09:22 AM |
| computer loops at safe mode,safe w/command prompt, etc. screen (XP Pro) | caver | Windows XP Support | 2 | 06-01-2008 12:09 PM |