|
pembepanter wrote: But in that way still it is not working. Yet another piece of non-information. One of the most frustrating things on CodeProject is people (like you) who post messages like, "I received an error", "my code is not working", "I tried but got nothing", etc. None of these statements tell us anything about your problem, so you leave us to guess what you are doing wrong, which is generally not possible.
|
|
|
|
|
I'm new at like these forums and about coding. I've written about this topic before. I had no information about this project. And you said me its your project do it via google. I researched and I wrote this code from the beginnig.
So I had an error and I asked people who can try to help me and answer my questions (not like you). You break my enthusiasm.
|
|
|
|
|
pembepanter wrote: So I had an error But you don't tell us what the error is. How can we guess, as we cannot see your screen, or read your mind? If you call the doctor and say, "I have a pain", do you expect him to know what type of pain, or where it is?
We are all trying to help answer these questions, but we cannot do it without the proper information.
|
|
|
|
|
the ReaderWriter is a class the can be used together with outStreamReader to write data to the file in java programming languange.
|
|
|
|
|
Looks like a pointless exercise. Not much interest in that.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
yeah but it is my school project
|
|
|
|
|
Hi I have a project but I do not have an an idea about the topic. Can you help me or give any resources about that topic?
This is my project:
In this project you will need to provide a solution to readers-writers problem in which several processes (readers and writers) are trying to access shared variables. Obviously, if two readers access the shared data simultaneously, no adverse effects will result, hence, they are allowed to access. However, if a writer and some other process (either a reader or a writer) access the data simultaneously, chaos may ensue. To ensure that these difficulties do not arise, we require that the writers have exclusive access to the shared data while writing to the data.
The solution must guarantee that:
If a writer has begun writing process, then
No additional writer can perform write function
No reader is allowed to read
If 1 or more readers are reading, then
Other readers may read as well
No writer may perform write function until all readers have finished reading
You are given Test class that use ReadWriteLock class and threads for the problem. You are expected to use Semaphore provided in the code.
Two operations on the semaphore is allowed; acquire() and release()
To do:
Implement methods of ReadWriteLock class given.
Also this my code test.java
package sync;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
public class Test {
public static void main(String [] args) {
ExecutorService executorService = Executors.newCachedThreadPool();
ReadWriteLock RW = new ReadWriteLock();
executorService.execute(new Writer(RW));
executorService.execute(new Writer(RW));
executorService.execute(new Writer(RW));
executorService.execute(new Writer(RW));
executorService.execute(new Reader(RW));
executorService.execute(new Reader(RW));
executorService.execute(new Reader(RW));
executorService.execute(new Reader(RW));
}
}
class ReadWriteLock{
private Semaphore S=new Semaphore(1);
public void readLock() {
}
public void writeLock() {
}
public void readUnLock() {
}
public void writeUnLock() {
}
}
class Writer implements Runnable
{
private ReadWriteLock RW_lock;
public Writer(ReadWriteLock rw) {
RW_lock = rw;
}
public void run() {
while (true){
RW_lock.writeLock();
RW_lock.writeUnLock();
}
}
}
class Reader implements Runnable
{
private ReadWriteLock RW_lock;
public Reader(ReadWriteLock rw) {
RW_lock = rw;
}
public void run() {
while (true){
RW_lock.readLock();
RW_lock.readUnLock();
}
}
}
Thank you
|
|
|
|
|
Firstly, this is your homework so you are expected to (at least try to) do the work.
Secondly, you have not asked an actual question.
You could start by doing some research, via Google, on the issues that you do not understand. Then, when you have a specific question, people will try to help you.
|
|
|
|
|
Message Closed
modified 17-Dec-19 0:46am.
|
|
|
|
|
You do not help people by doing their homework for them, as it just makes them less likely to try to do it themselves.
|
|
|
|
|
It's just a spam attempt, Richard, disguised on a plagiarized SO post.
"Five fruits and vegetables a day? What a joke!
Personally, after the third watermelon, I'm full."
|
|
|
|
|
|
I am generating barchart using jFreeChart and i need to make a customize content tooltip for the bar and here is my customized function on StandardCategoryToolTipGenerator and the problem right now is.. when mouse point to the bar the tooltip does not show
class MyTooltipGenerator extends StandardCategoryToolTipGenerator
{
@Override
public String generateToolTip(CategoryDataset dataset, int series, int category)
{
return "generateToolTip";
}
@Override
public String generateLabelString(CategoryDataset dataset, int row, int col)
{
return dataset.getColumnKey(col) + " " + dataset.getValue(row, col);
}
};
Both StandardCategoryToolTipGenerator and BarRender are customized as below:
MyTooltipGenerator std = new MyTooltipGenerator();
BarRenderer renderer = new MyBarRenderer();
when generating the content of the tooltip i make is as below:
BarRenderer rr = (BarRenderer) plot.getRenderer();
std.generateLabelString(dataset, row, column);
std.generateToolTip(dataset, row, column);
rr.setBaseToolTipGenerator(std);
plot.setRenderer(rr);
Problem now is the tooltip are NOT able to show.. is the tooltip required certain FORMAT? cause my plan is make the tooltip to be look like:
Quaitity: 50
Percetage: 80%
when the mouse point to the bar and it cannot display like above
|
|
|
|
|
|
I am looking for a medium size open-source project on Github that extensively uses automated tests and the test suites are very well. The testing framework they use is not important but I guess I would prefer JUnit.
I am seeking to see the "state of art" in usage of automated tests in a software project..
Please let me know your opinions and suggestions.
|
|
|
|
|
Member 14677234 wrote: Please let me know your opinions and suggestions. If you are looking for something on Github, you are unlikely to find it here.
|
|
|
|
|
Hi!
I have come up with an idea for an app, and as I googled, I understood that my app should be using Java. So we produce collars for pets and we want to develop some kind of service that could track the current location of a pet and how active it is at the moment.
I don't think that a freelancer would be able to make it, so we're thinking about hiring an outsourcing/offshoring IT company. Any advice about choosing a Java company? Or maybe you have some companies in mind which could help us with the app?
Thanks!
|
|
|
|
|
You are starting from the wrong position. Forget about which programming language to use and concentrate on the actual requirements of your application. The first thing you need is a fairly detailed design spec which you can use to get quotes from different companies. Let the professionals advise on what language to use, based on their experience.
|
|
|
|
|
Thank you very much for the advice, Richard! I'll stick to it
|
|
|
|
|
Your assumption that "outsourcing / offshoring" is somehow better than a "freelancer" is faulty. You can (and will) get hosed by anybody; especially if you're not an IT "expert" yourself. Be especially wary of the "up front" payment requirement. Anyways, a "Fitbit" "collar" solves half your problems.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
I am new to Java, but to expand my knowledge of it. Below is a project that I'm having a very, very difficult time completing. I need to create a method that passes in a two dimensional string array and then sorts the array by the second element.
Method sortContacts()
o Declared as a public static method, it should take a two-dimensional String array as a parameter,
and an integer value for the number of contacts in the array
o Returns nothing
o Sorts the contents of the contact list given as a parameter using the lastName as the sorting
field
o You may use any of the sorting mechanisms described in the text (bubble, insertion or selection)
o Key concept: as you implement the sort, the trick is to identify the dimension for the values you
are comparing and how they relate to the values from your loops.
o Hints:
Do not rely on the array’s length for your loops, instead use the value from the number
of contacts
Your temp variable will be an array of size 3, String[] temp = new String[3];
You will need to use the string1.compareTo(string2) method to compare two strings.
My biggest problem is where to put the temp array.
Sample data: (first name, last name, phone number)
String [][] contactsArray = {
{"Emily","Watson","913-555-0001"},
{"Madison","Jacobs","913-555-0002"},
{"Joshua","Cooper","913-555-0003"},
{"Brandon","Alexander","913-555-0004"},
{"Emma","Miller","913-555-0005"},
{"Daniel","Ward","913-555-0006"},
{"Olivia","Davis","913-555-0007"},
{"Isaac","Torres","913-555-0008"},
{"Austin","Morris","913-555-0009"}
<pre>public static void sortContact(String[][] contactsArray, int numContacts) {
String[] temp = new String[3];
String [] words = contactsArray[3];
for(int i = 0; i < numContacts-1; i++)
{
int smallest = i;
for(int j = i + 1; j < numContacts-1; j++)
{
System.out.println("First: "+words[j]+" " +"Second "+words[i]);
if(words[j].compareTo(words[i]) < 0)
smallest = j;
}
words[i] = words[smallest];
words[smallest] = temp[i];
}
}
There are tons of examples for integer arrays but not a lot for string arrays,
Any suggestions are appreciated.
|
|
|
|
|
Sorting strings is just the same as sorting any other type. The only difference is how you compare the two items to see which should come first. Also, it is not clear exactly what your problem is.
|
|
|
|
|
I need my output to look like this (without the quotes or braces):
{"Brandon","Alexander","913-555-0004"},
{"Joshua","Cooper","913-555-0003"},
{"Olivia","Davis","913-555-0007"},
{"Madison","Jacobs","913-555-0002"},
{"Emma","Miller","913-555-0005"},
{"Austin","Morris","913-555-0009"},
{"Isaac","Torres","913-555-0008"},
{"Daniel","Ward","913-555-0006"},
{"Emily","Watson","913-555-0001"}
I'm new to discussion boards so I may not be presenting the questions/answers properly. Any suggestion about how to explain better are appreciated also.
|
|
|
|
|
Your question states that you are to sort a two dimensional array, but I do not see how that matches with this data. I do not know if this is your homework or you picked a question from some other website. Either way you need to clearly state the structure of the input data, and how it needs to be changed by your code.
|
|
|
|
|
I'm sorry if I misspoke about it being only a two dimensional array.
My array is is set up as
String [][] contactsArray = new String[30][3]; (data provided in first post)
I'm passing the multidimensional array into the Method sortContacts() as one of the parameters. Once the data is passed, I need to sort the array based on the second element (last name).
I know how to use the sample coding below for a single string, but can't figure out how to apply this to a multidimensional array
for (int i = 0; i < num; i++)
{
for (int j = i + 1; j < num; j++)
{
if (names[i].compareTo(names[j])>0)
{
temp = names[i];
names[i] = names[j];
names[j] = temp;
}
}
}
|
|
|
|
|