@Override public final void setStrand(Strand strand) { if (this.strand != null) throw new IllegalStateException("Strand already set to " + strand); this.strand = strand; this.name = (name != null ? name : strand.getName()); mailbox.setStrand(strand); }
/** * Returns a string identifying this lock, as well as its lock * state. The state, in brackets includes either the String * {@code "Unlocked"} or the String {@code "Locked by"} * followed by the {@linkplain Strand#getName name} of the owning strand. * * @return a string identifying this lock, as well as its lock state */ public String toString() { Strand o = sync.getOwner(); return super.toString() + ((o == null) ? "[Unlocked]" : "[Locked by strand " + o.getName() + "]"); }
/** * Returns a string identifying this lock, as well as its lock state. * The state, in brackets, includes either the String {@code "Unlocked"} * or the String {@code "Locked by"} followed by the * {@linkplain Strand#getName name} of the owning strand. * * @return a string identifying this lock, as well as its lock state */ public String toString() { Strand o = sync.getOwner(); return super.toString() + ((o == null) ? "[Unlocked]" : "[Locked by strand " + o.getName() + "]"); } }
@Override public String toString() { String className = getClass().getSimpleName(); if (className.isEmpty()) className = getClass().getName().substring(getClass().getPackage().getName().length() + 1); final Strand strand = runner.getStrand(); final String strandName = (strand != null ? strand.getName() : "null"); // strand.getClass().getSimpleName() + '@' + strand.getId() return className + "@" + (getName() != null ? getName() : Integer.toHexString(System.identityHashCode(this))) + "[owner: " + strandName + ']'; }
@Override public void uncaughtException(Strand s, Throwable e) { System.err.print("Exception in Fiber \"" + s.getName() + "\" "); if (e instanceof NullPointerException || e instanceof ClassCastException || Exceptions.unwrap(e) instanceof NullPointerException || Exceptions.unwrap(e) instanceof ClassCastException) System.err.println("If this exception looks strange, perhaps you've forgotten to instrument a blocking method. Run your program with -Dco.paralleluniverse.fibers.verifyInstrumentation to catch the culprit!"); System.err.println(e); Strand.printStackTrace(threadToFiberStack(e.getStackTrace()), System.err); checkInstrumentation(ExtendedStackTrace.of(e), true); } };