Mea Cook

Greenhorn
+ Follow
since Jan 31, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Mea Cook

Thank you Bert! I am only few days on ranch, but I like it very much.

I'll do my best and next time write the full questions not only code.

This question is resolved for me and I close it
Really speaking I don't understand te role of synchronized in this context. Can anybordy help?



this is the same as



What object will be locked: from class Thread or Messager? And how long?
I thought, that if 1 Thread is locked, then runs to the end the 2 Thread and then the 1 Thread runs to the end.
But the answer shows, it is not correct...

Thank you
Hello all,

I have some problems with SELF TEST, exercise 1 (K&B, Java 1.5, Chapter 9, page 733)

According to the book the answer is Wallace-1 Gromit-1 Gromit-2 Wallace-2

I compiled the code and got another result. Wallace-1 Wallace-2 Gromit-1 Gromit-2




Thank you all in advance
Thank you! It works!!!

I have quation about:

why setChar(0, 'A' + 1) doesn't work and

why 3 steps with a temporal variable c are need:

char c;
c = s.charAt(0);
c++;
s.setChar(0, c);

Must I open a new topic?

Best regards
Ankit, I changed the code. Now I get output. But only A's...

I edited it.

Now I have anothe Problem: NullPointerException. Ist here a problem with synchronisation?

May be it is easy, but I don't know how to increment from A to B... and so on using charAt
Yes, I know the type of the return value. But it isn't my problem.

And how can I increment a letter please??? s.charAt(0) + 1??? It doesn't work
Sorry but I am still not on the road
Thank you,

but I am still by this exercise...

I use in void run() for loop (0 to 99) and print 100 As, how can I use charAt(pos). I thought, I have at the beginning only 1 A in a StringBuffer-Object...And the value of StringBuffer doesnt change during 100 iterations...
And after 100 iterations I must skip to B. Must I do another loop do... while? And how can I skip? if (s.charAt(0) eq 'A')??? But this is not OK if I whant to skip from 'B' to 'C'


Thank you in advance
Hello all,

I have some problems with te exercise 9-2, Chapter 9, p. 710-711

The result must be 100 As, 100 Bs, 100 Cs

In the book are follows steps described:
1. create a class and extend the Tread class (OK, no problem)
2. override te run of Thread. This is were te synch block will go (OK)
3. create a constructor tat accept StringBuffer (OK)
4 lock StringBuffer object (OK)
5 within block output StringBuffer 100 times and then increment te letter in the StringBuffer???
6. in main() create StringBuffer object using letter A, create 3 instances and start 3 of them (OK)

Thank you very much